Open ckinmind opened 7 years ago
找到失败的原因了,是因为,我在开头引入了actions, 然后再render中也有actions
import actions from '../actions/appleAction';
所以要修改getAppleItem中的actions来源
getAppleItem(){
return this.props.apples.map(apple => {
if(!apple.isEaten){
return <AppleItem apple={apple} eatApple={this.props.actions.eatApple} key={apple.id} />
}
});
}
之前渲染AppleItem的方式是,在render的return中
但是当我将其抽成一个方法的时候,发现吃苹果的操作失效了