1.scroll-into-view绑定一个变量(子节点的id)
<scroll-view scroll-y="true" scroll-into-view="{{ toView }}" style="height:{{h}}">
<view class="content" wx:for="{{dataA}}" wx:key="item" id='msg-{{index}}'></view>
</scroll-view>
2.页面周期给变量赋值最后一个节点的id
onShow: function () {
let that=this;
that.setData({
toView: "msg-" + (that.data.dataA.length - 1),
})
},
3.这样默认的最新消息就会在消息容器的底部
网友评论