state 和 props 主要的区别在于 props 是不可变的,而 state 可以根据与用户交互来改变。
React Props 语法
state 和 props 主要的区别在于 props 是不可变的,而 state 可以根据与用户交互来改变。
React Props 示例
var HelloMessage = React.createClass({ render: function() { return <h1>Hello {this.props.name}</h1>; }}); ReactDOM.render( <HelloMessage name="php.cn" />, document.getElementById('example')
热门推荐
- Weex和React Native的区别是什么?
- react中fragment是什么?
- React中const是什么
- react中如何引入样式
- React必知必会的35个面试题
- vue和react状态管理有啥区别?