1、overflow:scroll生成的滚动条的控制
当页面刷新到一个新的页面的时候,假如存在关于信息的滚动条,多数时候我们会要求数据展示的是最新的。
<div class="history-content" ref="historyContent">
<div class="apply-history flex-row" v-for="(item,indexs) in list.time_list" :key="indexs">
<div class="time">{{item.created_at_text}}</div>
</div>
methods:
//放在函数中获取数据之后否则容易失效
this.$nextTick(() =>{
this.$refs.historyContent.scrollTop = this.$refs.historyContent.scrollHeight;
})
.history-content{
width: 100%-1.2rem;
height: 11.57rem;
padding: 0.8rem 0.6rem;
overflow: auto;
}
2、关于ref属性是可以获取vue中的dom元素并且对相应标签进行操作
使用方法:this.$refs.ref的内容
document.getElementById()和this.$refs.ref的内容等效
最终效果图