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方式