react.js - react es6 怎么设置默认的props 于 state
本文介绍了react.js - react es6 怎么设置默认的props 于 state的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
如何写
getDefaultProps
getInitialState
非<Hello name="1111" />这样设置props
class Hello extends React.Component {
render() {
return <div>Hello {this.props.name} - {this.state.n}</div>;
}
}
ReactDOM.render(
<Hello />,
document.getElementById('container')
);
解决方案
https://babeljs.io/blog/2015/06/07/react-on-es6-plus 这里有详细的解答
中文 http://blog.mcbird.cn/2015/09/11/react-on-es6-plus/
这篇关于react.js - react es6 怎么设置默认的props 于 state的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文