美文网首页
taro mobx问题

taro mobx问题

作者: wangwing | 来源:发表于2019-05-29 13:40 被阅读0次

在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>
)

相关文章

网友评论

      本文标题:taro mobx问题

      本文链接:https://www.haomeiwen.com/subject/jpwyzqtx.html