安装:
npm install classnames
功能:
将true的class 显示出来,false 的隐藏
参考文档:https://manofhustle.com/2015/01/19/dynamically-add-classes-react-classset/
demo:
var classNames = require('classnames');
var HelloWorld = React.createClass({
render: function () {
var classes = classNames({
"important": true,"normal": true,"noclass":false
});
return <div>
<input type="text" className={classes}/>
</div>
}
})