vue中出现横向滚动条,默认滑动到最右侧进行内容展示
作者:互联网
1.html
<div ref="scrollRef" class="box">
<!-- 由内容撑起滚动条 -->
</div>
2.css
.box{
width: 100%;
overflow-x: scroll;
overflow-y: hidden;
&::-webkit-scrollbar {
display: none;
}
}
3.js
//获取完数据后,执行
let height = this.$refs.scrollRef.clientWidth;
this.$refs.scrollRef.scrollTo(height,0);
标签:vue,scrollTo,refs,scrollRef,height,滚动条,滑动,overflow 来源: https://blog.csdn.net/weixin_44326389/article/details/120193490