0
function onClick(event) {
console.log(event); // => nullified object.
console.log(event.type); // => "click"
const eventType = event.type; // => "click"
setTimeout(function() {
console.log(event.type); // => null
console.log(eventType); // => "click"
}, 0);
// Won't work. this.state.clickEvent will only contain null values.
this.setState({clickEvent: event});
// You can still export event properties.
this.setState({eventType: event.type});
}
爲什麼event
已經是作廢的對象,我們仍然可以得到event.type
價值? 是不是指的是event = {type:null}
?
setTimeout(function() {
console.log(event.type); // => null
console.log(eventType); // => "click"
}, 0);
爲什麼和eventType = 'click'
?
你能教我這段代碼的每一行嗎? ...
看起來'console.log(e)'是Asyn,但爲什麼不是'console.log(e.type)'? – Liuuil
事件合併'console.log(event.type)'==='console.log(null.type)'? – Liuuil