We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1768 Description
[问题描述:computed 无法检测 mapState 元素变化]
computed: { ...mapState({ article: state => state.article.article, likeArticleList: state => state.article.likeArticleList, }), // 无法 computed 来自 computed 的元素 isLiker() { let is = false; if(this.article && this.likeArticleList) { is = this.likeArticleList.indexOf(this.article.articleId) !== -1; } return is; }, }
在reducer 或者组件的methods 可以检测到变化,但是当computed 的对象是两个来自 mapState 的元素时,无法检测到变化
isLiker 值一直是 false;只在组件创建的时候计算过一次
isLiker 值根据mapState 元素变化动态计算结果
The text was updated successfully, but these errors were encountered:
临时解决办法: 在组件的 onShow 中启动 setInterval, 定时2 秒计算对应值
Sorry, something went wrong.
为何不放在store中去计算,getters抛出来就行了
getters 貌似用不了。參看 issue#2411
No branches or pull requests
#1768 Description
[问题描述:computed 无法检测 mapState 元素变化]
Environment
Reproduce
在reducer 或者组件的methods 可以检测到变化,但是当computed 的对象是两个来自 mapState 的元素时,无法检测到变化
Observed Results
isLiker 值一直是 false;只在组件创建的时候计算过一次
Expected Results
isLiker 值根据mapState 元素变化动态计算结果
The text was updated successfully, but these errors were encountered: