React中的style样式
在react中使用style样式时,先创建一个对象,对象的内容时css属性以及属性值,在使用的时候,将对象绑定在相应的元素上
<body> <div id="app"></div> </body> <script type="text/babel"> const style={ color:'pink', fontSize:'30px', border:'1px #666 solid', }; class Test extends React.Component{ render(){ return ( <div style={style}> Hello World! </div> ) } } ReactDOM.render( <Test/>, document.getElementById('app') ) </script>
更多web前端知识,请查阅 HTML中文网 !!