Javascript Vue.js-在计算机中使用本地方法是否不好?

Javascript Vue.js-在计算机中使用本地方法是否不好?,javascript,vue.js,vuejs2,vue-component,vuex,Javascript,Vue.js,Vuejs2,Vue Component,Vuex,我使用Vuex状态作为事件(eventBus)的触发器 我通过以下方式触发事件: this.$store.dispatch('triggerRefetch'); 并通过以下方式进行处理: computed: { trigger: function(){ return this.$store.getters['triggerFlag'] } }, watch: function(newV, oldV){ this.handleTrigger(); },

我使用Vuex状态作为事件(eventBus)的触发器

我通过以下方式触发事件:

this.$store.dispatch('triggerRefetch');
并通过以下方式进行处理:

computed: {
    trigger: function(){ 
        return this.$store.getters['triggerFlag'] 
    }
},
watch: function(newV, oldV){
    this.handleTrigger();
},
在这里,我不需要新值,也不需要旧值。因此,可以只使用computed进行如下操作:

computed: {
    trigger: function(){ 
        this.handleTrigger();
        return this.$store.getters['triggerFlag'] 
    }
},

对Vuex(事件总线)使用这种方式是否不好?此外,还有更好的方法吗?

我认为在计算属性中运行一些额外的逻辑是一种不好的做法,属性只是一个返回一些数据的属性,而不是一个运行一系列逻辑的函数或方法,保留第一种在可读性和可扩展性方面最好的方法,这使您的代码能够遵循一些清晰的流程

computed: {
    trigger: function(){ 
        return this.$store.getters['triggerFlag'] 
    }
},
watch: {
 trigger: function(){
    this.handleTrigger();
},