<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的位置