uniapp写滚动到最底部代码
时间: 2023-12-23 15:04:54 浏览: 29
你好,关于uniapp滚动到最底部的代码,您可以参考以下示例代码:
在 template 中:
```
<scroll-view scroll-y="true" refresher-enabled="{{refresherEnabled}}" refresher-triggered="{{refresherTriggered}}" scroll-into-view="{{toView}}" bindscrolltolower="scrollToBottom">
<view id="content">
<!--此处放置需要滚动的内容-->
</view>
</scroll-view>
```
在 script 中:
```
onLoad: function () {
var that = this;
that.setData({
toView: 'content'
});
},
scrollToBottom: function (e) {
var that = this;
//获取页面根节点信息
wx.createSelectorQuery().select('#content').boundingClientRect(function (rect) {
//将页面滚动到底部
wx.pageScrollTo({
scrollTop: rect.bottom
});
}).exec();
}
```
以上代码可以实现滚动到页面底部,您可以根据需要进行修改。如果您还有其它问题,欢迎继续询问。