vue双向监听proxy

console.log('判断页面是否有滚动条', this.hasScrollbar)
    const that = this
    that.count = 0 // 计数
    that.scrollProxy = new Proxy({
      hasScrollToEnd: !that.hasScrollbar,
      hasCounted: false,
    }, {
      set(obj, property, value) {
        console.log('setsetset', obj, property, value)
        Reflect.set(obj, property, value)
        if (obj.hasScrollToEnd && obj.hasCounted) {
          that.count += 1
          if (that.count === 1) {
            that.readNewsForAddDrawChance()
          }
        }
        console.log(obj.hasScrollToEnd, obj.hasCounted)
        return true
      },
    })

  mounted

posted @ 2020-12-01 15:13  糖锡  阅读(134)  评论(0)    收藏  举报