赞
踩
最近一直写React,慢慢就对里面的一些实现很好奇。最好奇的就是自定义标签的实现和this.setState的实现。这里不分析JSX是如何解析的,所有组件都用ES5方式编写。
渲染时候,我们会调用render方法。类似下面这样:
var SayHi = React.createClass({
getInitialState: function() {
return {verb: 'say:'};
},
componentWillMount: function() {
console.log('I will mount');
},
componentDidMount: function() {
console.log('I have mountedCopyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。