我的场景是这样的:
在组件A中,通过 created
钩子获取后端数据
created(){
this.$store.dispatch('getArticle' , this.$route.params.slug);
},
computed:{
...mapState([
'article' //article state
])
},
问:如何在 mounted
里获取 this.article
的值 ?
我的场景是这样的:
在组件A中,通过 created
钩子获取后端数据
created(){
this.$store.dispatch('getArticle' , this.$route.params.slug);
},
computed:{
...mapState([
'article' //article state
])
},
问:如何在 mounted
里获取 this.article
的值 ?
5 回答4.9k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答4.8k 阅读✓ 已解决
4 回答4.4k 阅读✓ 已解决
4 回答1.9k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
在mounted的时候.getArticle还没有完成.是拿不到的
既然你computed了article.
你就可以watch article.
只要article变化.做相应处理