查漏补缺——说说Vuex中的getters方法
作者:互联网
问题
如题所示
答案
相关源码:
notice() {
return this.$store.getters.notice
}
const getters = {
loading: state => state.loading,
runTimeInterval: state => state.runTimeInterval,
notice: state => state.websiteInfo?state.websiteInfo.notice:''
}
综上所述,Vuex中getters方法就和Vue实例中计算属性一样,它的作用就是将过滤出来的数据再提取出来进行共享。以下代码用到的过滤器是三目运算符:
notice: state => state.websiteInfo?state.websiteInfo.notice:''
``
标签:notice,loading,Vuex,getters,查漏,state,websiteInfo 来源: https://www.cnblogs.com/Huang-zihan/p/16451952.html