计算属性出现警告信息,标识在第3和第10行的this上

来源:17-23 购物车详情页实现(3)

Rengar_fh

2018-01-21

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;
}

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

写回答

1回答

ustbhuangyi

2018-01-21

你的 fold 定义在哪里的?

0
10
DAOLANFLER
回复
Rengar_fh
今天再看了一下,其实就是vuejs 的 eslint-plugin-vue 中的一条rule,vue 认为在计算属性中直接改变 this.someproperty 会有副作用。加上 // eslint-disable-next-line 忽略这个规则就可以了
2018-04-08
共10条回复

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

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

9868 学习 · 4162 问题

查看课程