vue 中如何监听滚动事件?

vue 中如何监听滚动事件?

阅读 39.9k
2 个回答
data () {
  return {
    scrolled: false
  };
},
methods: {
  handleScroll () {
    this.scrolled = window.scrollY > 0;
  }
},
ready () {
  window.addEventListener('scroll', this.handleScroll);
}
推荐问题