需求:博客文章的目录,点击目录,滚动到对应的内容
<html>
<div class="box">
<button>按钮</button>
<ul>
<li v-for="(item,index) in 100"
:key="index"> aa{{item}}
</li>
</ul>
<div class="wait">等着你...</div>
</div>
</html>
实现如下:
<script>
jump(){
document.querySelector(".wait").scrollIntoVi ew({
behavior:"smooth"
})
}
</script>
//样式要出现滚定条
<style>
.box {
height:200px;
overflow-y:auto
}
</style>