taro mobx问题

在store里设置变量wordArr: [{},{},{},{},{}],
组件里 wordArr.slice()需要加slice()这样在组件里更新了wordArr里的内容后,render上才会更新变动的数据,slice()相当于一次浅拷贝(一级拷贝,再深入就不行了)

            return item.name && <View className='li' key={index} dataIndex={index} dataWord={item.name} onClick={this.onResult} >{item.name}<span></span></View>
        })```

如果在store里设置了 counter:{count:0}
那么在使用的时候,
//错误
const { counterStore: { counter } } = this.props  
return (
  <Text>{counter.count}</Text>
)
//正确
const { counterStore: { counter:{count} } } = this.props  
return (
  <Text>{count}</Text>
)

转载于:https://www.jianshu.com/p/457e9698b750

猜你喜欢

转载自blog.csdn.net/weixin_34067980/article/details/91204919
今日推荐