美文网首页
react生命周期钩子、jsx

react生命周期钩子、jsx

作者: 他方l | 来源:发表于2018-06-25 10:34 被阅读0次

react生命周期钩子

    componentWillMount:组件首次渲染之前调用
    componentDidMount:在首次真实的DOM渲染后调用(仅此一次)或请求外部接口数据时使用
    componentWillUnmount:组件卸载后




   JSX

          <div className="wrapper" title="">
                   <button onClick={this.toggle.bind(this)}>显示/隐藏</button>
            </div>


         {

            tagName:"div",
            attrs:[className:"wrapper"]
            childen:[
                  {
                  tagName:"button",
                  attrs:['onClick':fn]
                  }

               ]

              }



          react添加样式:
              1.直接引入css  [推荐]
              2.js方式

相关文章

网友评论

      本文标题:react生命周期钩子、jsx

      本文链接:https://www.haomeiwen.com/subject/lvweyftx.html