【vue】div元素内的滚动条 滚动到指定位置
作者:
吃肉肉不吃肉肉 | 来源:发表于
2022-01-03 17:03 被阅读0次<template>
<div class="GoodList">
<div>123</div>
<div>123</div>
<div>123</div>
<div>123</div>
<div>123</div>
<div>123</div>
<div>123</div>
<div>123</div>
<div>123</div>
</div>
</template>
<script>
export default{
mounted(){
this.scrollToBottom()
},
methods:{
scrollToBottom(){
this.$nextTick(()=>{
let box = this.$el.querySelector(".GoodList")
GoodList.scrollTop = 40 //滚动到距离元素顶部 40px
})
}
},
}
</script>
<style>
.GoodList{
height: 200px;
overflow-y: scroll;
}
</style>
本文标题:【vue】div元素内的滚动条 滚动到指定位置
本文链接:https://www.haomeiwen.com/subject/czwxcrtx.html
网友评论