<div id="app"> <div class="content"> <span>{{ scrollY }}</span> </div> </div> new Vue({ el: '#app', data: { scrollY: 0 }, mounted() { window.addEventListener('scroll', this.handleScroll); }, methods: { handleScroll() { this.scrollY = window.scrollY; } } })