有两种方式
一、scroll-into-view
<scroll-view scroll-y scroll-into-view='{{toView}}' style='height: 440px;overflow: auto; '>js中通过setdata来设置toView为最底部view的id值,比如msg-2
<view id="msg-1">1</view> <view id="msg-2">2</view></scroll-view>
二、scrolltop
设置
<scroll-view scroll-y :scroll-top="scrollTop" id="scrollview" style="400px;overflow: scroll; '">
<view id="msglistview"><view>1</view> <view>2</view></view></scroll-view>
js来计算scrolltop并setdata
let that = this
let query = uni.createSelectorQuery()
query.select('#scrollview').boundingClientRect()
query.select('#msglistview').boundingClientRect()
query.exec((res) => {
// console.log(res)
if(res[1].height > res[0].height){
that.scrollTop = res[1].height - res[0].height;
console.log( that.scrollTop );
}
})
网友回复
有没有类似豆包pc端ai大模型编程代码块折叠右侧流式输出带预览的前后端代码?
nodejs有没有很快的目录爬虫和通配符文件查找库?
js如何流式输出ai的回答并折叠代码块,点击代码块右侧可预览代码?
ai大模型如何将文章转换成可视化一目了然的图片流程图图表?
大模型生成html版本的ui原型图和ppt演示文档的系统提示词怎么写?
rtsp视频直播流如何转换成websocket流在h5页面上观看?
为啥coze会开源工作流agent coze studio?
如何检测网页是通过收藏夹打开的?
python如何实现类似php的http动态脚本请求处理响应代码?
js如何实现类似php的http动态脚本请求处理响应代码?