JSX属性绑定
<script src="format_utils.js"></script><script type="text/babel">class App extends React.Component {constructor(){super()this.state = {title: '标题',imgUrl: 'https://p1.music.126.net/gacBlG1n5qDYaheqsemMNA==/3250156380424409.jpg',link: 'https://www.baidu.com',active: true}}render(){const {title, imgUrl, link, active} = this.statereturn (<div>{/* 1.绑定普通属性 */}<h2 title={title}>标题</h2><img src={getImgUrl(imgUrl)} alt="" /><a href={link} target="_blank">百度</a>{/* 2.绑定class */}<div className={"box title " + (active ? "active" : "")}>我是div</div><label htmlFor=""></label>{/* 3.绑定style */}<div style={{color: 'red', fontSize: "50px"}}>我是div</div></div>)}}ReactDOM.render(<App />, document.querySelector('#app'))</script>
视频 03 第 33 分钟
