https://github.com/lixiaoyan/x-view
一个有意义的轮子(伪), 三天写出来的产物, 仿 React 的 API.
一个 example:
var Button = x.createClass({
propTypes: {
text: x.type.string
},
render: function() {
return x.createElement("button", {
"on-click": this.emit.bind(this, "button-click")
}, [this.props.text]);
}
});
x.register("x-button", Button);
x.render(document.body, x.createElement("x-button", {
text: "Hello!",
"on-button-click": function() {
console.log("You clicked the button.");
}
}));
目前还不稳定, 只是刚能用了而已, Shadow DOM 支持正在开发中...