【发布时间】:2021-05-19 23:03:32
【问题描述】:
我正在使用Vuex,在Getter Foo function 内部我在数组中返回两个值:
return ["Try Again"] 或 return ["Data result", data],在计算中,我正在检查 array length 并根据结果返回
computed:{
Foo: function(){
const getFoo = this.$store.getters.Foo;
if(getFoo.length === 1) {
this.existFoo = false
return getFoo[0]
}
this.existFoo = true
return getFoo
}
}
但是我遇到了这个错误,即使阅读其他帖子我也无法解决它
34:9 错误“Foo”计算属性中的意外副作用 vue/计算属性中的无副作用
37:7 错误意外 “Foo”计算属性的副作用 vue/no-side-effects-in-computed-properties
【问题讨论】: