与scroll相关的方法:
4个window对象下:scrollX、scrollY、scrollTo、scroll(作用和scrollTo一样)
4个Element对象下:scrollWidth、scrollHeight、scrollLeft、scrollTop
示例:
<script>
export default {
mounted () {
window.addEventListener('scroll', this.handleScroll)
},
methods: {
handleScroll () {
console.log(window.scrollY)
console.log(window.scrollX)
console.log(window.scrollX)
}
}
}
</script>