Computed property was assigned to but it has no setter问题解决

提示此问题,是因为在computed 里面定义的属性 只有一个return返回。因为在其他地方进行了赋值操作,导致提示此错误!如下代码所示:

更改之前的代码:

 computed: {
            drCountData() {
                return this.$store.state.drCountData;
            },
        },

解决办法:修改成如下的代码:

computed: {
            drCountData: {

                get(){
                    return this.$store.state.drCountData;
                },
                set(v) {
                    this.countData = v
                }

            },
            

你可能感兴趣的:(vue,vue.js)