<template>
<div ref="obtain"></div>
<template/>
<script>
export default {
data() {
return {}
},
mounted() {
// 滚动条的获取
window.addEventListener('scroll', this.handleScrollx, true)
},
methods: {
handleScrollx() {
console.log('滚动高度', window.pageYOffset)
console.log('距离顶部高度', this.$refs.obtain.getBoundingClientRect().top)
}
}
}
</ script>