微信小程序 scroll-view 使用注意事项

283 阅读1分钟

微信小程序 scroll-view 注意事项

1、下拉刷新一直处于加载状态

refresher-triggered 的值要在触发刷新前设置为 true 完成刷新后 设置为 false 不能省略触发前设置为 true 的步骤。

2、scroll-into-view 有时生效有时不生效

原因 id 有数字开头的不合法 id 应该统一以 字母或者下划线开头

3、createIntersectionObserver 有时生效有时生效

这个一般用于判断消息是否已读

一、原因同上 id 有数字开头的不合法 id 应该统一以 字母或者下划线开头

二、创建 IntersectionObserver 的时候没有传递正确的实例 解决办法:

const pages = getCurrentPages()
const messagesPage = pages[pages.length - 1]
const observer = createIntersectionObserver(messagesPage)

(完)