var FancyCheckbox = React.createClass({
render: function() {
var { checked, ...other } = this.props;
var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
return (
<div {...other} className={fancyClass} /> //***这里提示有错误***
);
}
});
React.render(
<FancyCheckbox checked={true} onClick={console.log.bind(console)}>
Hello world!
</FancyCheckbox>,
document.getElementById('example')
);
我用chome的console里看到如上提示有错误,手册...other为什么不能用
这一个语句是用到了 es6 解构语法,需要配合 babel 编译js才可以运行。
参考 http://es6.ruanyifeng.com/#docs/destructuring