Error Unexpected side effect in "listShow" computed property

Why does this problem arise and how can it be solved?
clipboard.png

       listShow () {
        if (!this.totalCount) {
          this.fold = true;
          return false;
        }
        let show = !this.fold;
        if (show) {
          this.$nextTick(() => {
            if (!this.scroll) {
              this.scroll = new BScroll(this.$refs.listContent, {
                click: true
              });
            } else {
              this.scroll.refresh();
            }
          });
        }
        return show;
      }
Apr.29,2021

listShow is a computational attribute, which cannot be written directly. You need to use get and set, because some of the values have been modified.
both the toggleList and empty methods need to be modified.
there may be a better way, for reference only.

computed: {
  listShow: { // 
    get () {
      if (!this.totalCount) { //  0 
        return false
      }
      return this.fold
    },
    set () {
      if (!this.totalCount) {
        this.fold = false
      }
      if (!this.fold) {
        this.$nextTick(() => {
          //  better-scroll  refresh
          if (!this.scroll) {
            this.scroll = new BScroll(this.$refs.listContent, {
              click: true
            })
          } else {
            this.scroll.refresh()
          }
        })
      }
    }
  }
},
methods: {
  // 
  toggleList () {
    if (!this.totalCount) {
      return
    }
    this.listShow = false //  better-scroll  refresh
    this.fold = !this.fold //  this.fold  lisShow
  },
  // 
  empty () {
    this.selectFoods.forEach((food) => {
      food.count = 0
    })
    this.listShow = false // 
  },
}
Menu