2017-06-15 120 views
-1

我想学反应,并跨越这些代码来在网站上:https://www.reactenlightenment.com/react-state/8.2.html什么是changeMood功能的其他参数

我明白的代码做什么,但无法了解什么是参数“A”在改变功能。删除代码后运行代码,代码运行良好。

var MoodComponent = React.createClass({ 
    getInitialState: function() { 
    return {mood: ':|'}; 
    }, 
    changeMood:function(event, a){ 
    const moods = [':)',':|',':(']; 
    const current = moods.indexOf(event.target.textContent); 
    this.setState({mood: current === 2 ? moods[0] : moods[current+1]}); 
    }, 
    render: function() { 
     return (
     <span style={{fontSize:'60',border:'1px solid #333',cursor:'pointer'}} 
       onClick={this.changeMood}> 
       {this.state.mood} 
     </span> 
     ) 
    } 
}); 

回答

0

这并不意味着什么。

onClick只发送1个参数,这是一个由React创建的合成事件,用于处理跨浏览器兼容性。

欲了解更多信息,请检查React docs对处理事件的

+0

它是一个打字错误,它被列入代码? –

+0

我相信是这样,因为它不在那个范围内使用 – BravoZulu

+0

感谢您的信息 –

相关问题