sunny123456

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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

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

更改之前的代码:

 computed: {
            drCountData() {
                return this.$store.state.drCountData;
            },
        },
  • 1
  • 2
  • 3
  • 4
  • 5

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

computed: {
            drCountData: {
                get(){
                    return this.$store.state.drCountData;
                },
                set(v) {
                    this.countData = v
                }
            }, 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
https://blog.csdn.net/weixin_44994731/article/details/104302012
posted on 2022-03-23 08:54  sunny123456  阅读(1014)  评论(0编辑  收藏  举报