vue+node+mongodb高级资料

原创 IT大叔 教程 vue 63阅读 8 天前 举报

自定义指令
let scrollCallback = function (callback) {
let windowH = window.innerHeight
let getDocumentHeight = function () {
var body = document.body
var html = document.documentElement
return Math.max(
body.offsetHeight,
body.scrollHeight,
html.clientHeight,
html.offsetHeight,
html.scrollHeight
)
}
let scrollH = document.documentElement.scrollTop || document.body.scrollTop
if (windowH + scrollH >= getDocumentHeight() - (this.holder || 20)) {
callback()
}
}

let callBackWarpped

export default {
bind (el, binding, vnode) {
let holder
if (vnode.data && vnode.data.attrs && vnode.data.attrs['scroll-placeholder']) {
holder = parseInt(vnode.data.attrs['scroll-placeholder'])
} else {
holder = 20
}
callBackWarpped = scrollCallback.bind({el, holder}, binding.value)
window.addEventListener('scroll', callBackWarpped, false)
},

unbind: function () {
window.removeEventListener('scroll', callBackWarpped, false)
}
}

加群:813771196免费领取(加群需求看群介绍,不然是进不了的)

评论 ( 0 )
最新评论
暂无评论

赶紧努力消灭 0 回复