react里面用html标签,样式用classname无效把?只能用style={{}}?style=""都不行?
###使用className
代替class
, style={_style}
中的_style
只能是对象 不能是字符串.
import React from 'react';
class Demo extends React.Component {
render() {
return (
<div className="demo" style={{color: '#fff'}}>hello world!</div>
)
}
}
export default Demo;
两者都可以,一般都是利用类名写css,内联样式不推荐,会导致页面臃肿。