查漏补缺——说说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:''
``