在一个页面中我们想点击某个按钮,想让下面的内容上升到当前视图窗口(相当于我们滑动滚动条让指定内容上来)当我们点击图一技接口总数上面数字,页面滑到图二
![](https://i-blog.csdnimg.cn/blog_migrate/3fb319f8956ae5953d74323f78be159b.png)
图一
![](https://i-blog.csdnimg.cn/blog_migrate/fd842dd658fd9afea980a1819491e044.png)
图二
-
html代码片段:
<span @click="goDingyue">{{ form2.Api }}</span>
<div style="margin-bottom:10px" class="dingyue_box">
<assetsForm ref="assetsForm" :count-period="countPeriod" />
</div>
2.js代码片段:
goDingyue() {
this.$el
.querySelector('.dingyue_box')
.scrollIntoView({ block: 'start', behavior: 'smooth' })
},
3.小结:我们想跳到底部那个地方,让他在当前窗口展示,我们可以给所需要展示的加个div,使用类选择器,用原生的方法获取该div ,然后设置他滚动条滚动方式,就能实现该功能。