Unexpected side effect in "listShow" computed property

来源:17-21 购物车详情页实现(1)

xy36

2018-08-04

http://img.mukewang.com/szimg/5b6564c000017fc011380882.jpg

http://img.mukewang.com/szimg/5b6564c2000120df15921210.jpg

文件中listShow()

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;    

     }    

   }

报错了,不知道哪里出问题了,怎么解决呢?求指教


写回答

1回答

ustbhuangyi

2018-08-05

这是新版 Vue.js 的报警,不要在计算属性中做赋值操作, 可以尝试用 watch 来实现类似的逻辑

1
0

Vue.js2.5+cube-ui重构饿了么App(经典再升级)

掌握Vue1.0到2.0再到2.5最全版本应用与迭代,打造极致流畅的WebApp

9868 学习 · 4162 问题

查看课程