麦东西
麦东西
  • 发布:2020-04-19 21:45
  • 更新:2022-10-21 11:21
  • 阅读:2497

createIntersectionObserver 报错

分类:uni小程序sdk

使用uni.createIntersectionObserver(this);
微信小程序报错

Property or method "toJSON" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See

VM4841:1 TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
--- property '_renderProxy' closes the circle
at JSON.stringify (<anonymous>)

2020-04-19 21:45 负责人:无 分享
已邀请:
3***@qq.com

3***@qq.com

修改为
observer = this.createIntersectionObserver({
observeAll: true
});
即可

官方应给升级下 uni.createIntersectionObserver
对应情况编译成
this.createIntersectionObserver({
observeAll: true
});

  • 6***@qq.com

    感谢分享 不会报 JSON 错误 但是 observeAll 好像不生效了...

    报另一个错误"Error: "observe" call can be only called once in IntersectionObserver"

    2020-09-30 15:03

4***@qq.com

4***@qq.com

大佬解决了吗 我也是有这个问题 虽然好像没有影响

3***@qq.com

3***@qq.com

今天遇到同样的问题,之前没有,有可能是编译器升级了之后出现的,这个咋解决的?

6***@qq.com

6***@qq.com

mark 同求

2***@qq.com

2***@qq.com

将uni.createIntersectionObserver(this)改成this.createIntersectionObserver();只针对微信小程序

t***@126.com

t***@126.com

在data中添加一个toJSON属性就行了,
然后用回官方的用法,不用再改了

该问题目前已经被锁定, 无法添加新回复

  • 标题 / 粗斜体
  • 代码片段
  • 超链接 / 图片 / 视频
  • 列表 / 引用

文章内容较多时,可以用标题分段 :

## 大标题 
### 小标题

斜体 / 粗体 :

**粗体** 
*斜体*
***粗斜体***

代码片段 :

``` javascript
代码片段
```

超链接 :

[链接文字](链接地址) 例: [百度](http://www.baidu.com)

图片 :

![图片说明](图片地址) 例: ![百度logo](http://www.baidu.com/img/bdlogo.gif)

视频 :

!![视频说明](视频地址) 例: !![优酷视频](http://youku.com)

有序列表 :

1. 123
2. 123
3. 123

无序列表 :

- 123
- 123
- 123

引用 : ( 双回车后结束引用 )

> 引用内容
引用内容
引用内容