<scroll-view style='height:{{height}}' scroll-y scroll-into-view="{{toView}}" >
<view class="conversation-list p" style='height:{{height}}' id="sco" >
<view wx:for="{{recordsReal}} " id="msg-{{index}}">
</view>
</view>
</scroll-view>
//开始滚动
pageScrollToBottom () {
let that = this;
var query = wx.createSelectorQuery();
query.select('#sco').boundingClientRect(function (rect) {
that.setData({
height: rect.width + 'px'
})
}).exec();
that.setData({
toView:`msg-${that.data.recordsReal.length-1}`
})
},
//在发送成功时回调 pageScrollToBottom方法 ,
获取滚动dom的id ,toView等于当前一条id的位置