【发布时间】:2019-09-01 09:21:29
【问题描述】:
我想在滚动时移动一个元素,以便该元素始终在屏幕中。 但是位置没有更新。
我正在做的是这个。
<v-card class="item" :style="{ top: distance }">
</v-card>
...
data() {
return {
distance: 0,
}
}
methods: {
handleScroll() {
this.distance = window.scrollY
},
},
created() {
window.addEventListener('scroll', this.handleScroll)
},
destroyed() {
window.removeEventListener('scroll', this.handleScroll)
},
}
...
.item {
position: absolute;
}
我该怎么做?
【问题讨论】:
标签: vue.js vuejs2 vuetify.js