1 回答
TA贡献1834条经验 获得超8个赞
感觉你要的是这样的
<template>
<div class="scrollTop" @click="toTop">
...
</div>
</template>
<script>
export default {
name: 'scroll-top',
props: {
toBottom: {
type: Number,
default: 0
}
},
methods: {
toTop() {
document.documentElement.scrollTop = document.body.scrollTop = 0;
}
},
mounted() {
document.querySelector('.scrollTop').style.bottom = this.toBottom;
}
}
</script>
<style scoped>
.scrollTop {
display: fixed;
...
}
</style>
添加回答
举报