-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>
)
}
});
它是一个打字错误,它被列入代码? –
我相信是这样,因为它不在那个范围内使用 – BravoZulu
感谢您的信息 –