scroll-view 滑动到底部
发布于 5 年前 作者 napan 5832 次浏览 来自 问答

打算想做一个聊天程序,增加了消息后, 怎么用程序控制scroll-view滑动到最底部?

5 回复

请问解决了吗?

<scroll-view class=“scrool-view” style=“height: {{ winHeight }}px” scroll-y=“true” scroll-with-animation=“true” scroll-into-view="{{ scrolltop }}" enable-back-to-top=“true”>

</scroll-view>


winHeight :

wx.getSystemInfo({
      success(res) {
        that.setData({
          winHeight: res.windowHeight - 150,
        });
      },
    });

scrolltop

let ch = {
      'text': word,
      'time': new Date().getTime(),
      'orientation': orientation
    };
    chatListData.push(ch);
    wx.setStorageSync('chatList', chatListData);
    var charlenght = chatListData.length;
    that.setData({
      chatList: chatListData,
      scrolltop: "roll" + charlenght
    });

@sincere 试试把!

解决了,感谢🙏

回到顶部