1
所以在下面的例子中,當你點擊按鈕時,爲什麼log.added
未定義?爲什麼React組件函數失去它們的屬性?
var log = function(){
console.log("X");
};
log.added = true;
App = React.createClass({
log: log,
showLog(){
this.log(); // X
console.log(this.log.added); // undefined
},
render(){return (
<button onClick={this.showLog}>Log</button>
)}
});