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
浙公网安备 33010602011771号