react入门
2016-07-29 11:04:23 0 举报
AI智能生成
react入门
作者其他创作
大纲/内容
HTML模板
基本方法
ReactDOM.render():
React.createClass():新建组件
this.props
this.props.children
React.Children.Map:遍历props.children
PropTypes:验证实例属性是否符合要求
ref:获取真实DOM节点;
this.refs[propName]:返回真实DOM节点
this.state:状态值
this.setState:修改状态值
getInitialState:定义初始状态值
组件的生命周期
生命周期三种状态
<b>Mounting:</b>已插入真实DOM
componentWillMount
<b>componentDidMount</b>
<b>Updating:</b>正在被重新渲染
componentWillUpdate
componentDidUpdate
<b>Unwounting:</b>移除真实DOM
componentWillUnwount
特殊状态
<b>componentWillReceiveProps:</b>已加载组件接受新的参数
<b>ShouldComponetUpdate:</b>判断是否重新渲染时调用
表单
定义<b>onChange</b>的回调函数函数
用<b> event.target.value</b>获取值
ajax
用<b>componentDidMount设置请求</b>
用 <b>this.setState</b>重新渲染UI
getDefaultProps:设置组件默认值
0 条评论
下一页