mounted() {
window.addEventListener(‘scroll’, this.handleScroll) // 监听滚轮事件
// window.onmousewheel = function () { //触发滚轮事件
// document.getElementsByClassName('boxBt')[0].style.position = 'fixed'
// let nnn = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
// console.log(nnn)
// document.getElementsByClassName('boxBt')[0].style.top = (324-nnn)+'px'
// }
}
methods: {
handleScroll () {
// document.getElementsByClassName(‘boxBt’)[0].style.position = ‘fixed’
// let nnn = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
// document.getElementsByClassName(‘boxBt’)[0].style.top = (324-nnn)+‘px’
div到浏览器顶部的距离
console.log(document.getElementById(‘div2’).offsetTop)
},
鼠标的划入/划出方法(改变div属性)采用overflow划定不