<scroll-view scroll-y="true" scroll-with-animation="true" style="height: 300rpx;" :scroll-into-view="chatViewId">
<view v-for="(item,index) in datalist" :key="index" class="contentbox" :id="'' + item.id">
<text class="t1" >{{item.name}}:</text>
<text class="t2">{{item.conten}}</text>
</view>
</scroll-view>
data() {
return {
chatViewId: '',
},
watch:{
datalist:{
handler(val,nervel){
console.log(nervel);
let len = this.datalist.length - 1;
const id = this.datalist[len].id;
this.chatViewId = '' + id;
},
deep:true
},
},
1 个回复
DCloud_uni-ad_HDX
用新闻模板试试 https://github.com/dcloudio/uni-template-news/blob/master/pages/news/index.nvue