收藏
回答

lottie-miniprogram一直报错“nodeId undefined”怎么处理?

Cannot read property \'nodeId\' of undefined
TypeError: Cannot read property \'nodeId\' of undefined
at Image.set [as src] (https://lib/WASubContext.js:2:667557)
at mp.set src [as src] (https://lib/WASubContext.js:2:739954)
at Object.r [as _createImageData] (https://miniprogram_npm/lottie-miniprogram/index.js:9:53749)
at Object.i [as loadAssets] (https://miniprogram_npm/lottie-miniprogram/index.js:9:53918)
at AnimationItem.preloadImages (https://miniprogram_npm/lottie-miniprogram/index.js:9:143984)
at AnimationItem.configAnimation (https://miniprogram_npm/lottie-miniprogram/index.js:9:144519)
..............

报错内容如上,这个是只有安卓机报错,比较多,还有一种是下面的,只有ios报错。

undefined is not an object (evaluating \'t.nodeId\')
set@https://lib/WASubContext.js:2:667556
src@https://lib/WASubContext.js:2:739950
r@https://usr//app-service.js:9290:72032
i@https://usr//app-service.js:9290:72218
.......

查看错误定位到 lottie-miniprogram/index.js的如图位置

使用代码如下,是完全按文档写。

wx.createSelectorQuery().in(this).selectAll('#welfare_lottie').node(res => {
 const canvas = res[0].node
 const context = canvas.getContext('2d')
 canvas.width = 144
 canvas.height = 144
 lottie.setup(canvas)
 this.ani = lottie.loadAnimation({
  loop: true,
  autoplay: true,
  path: 'https://img.picka.com.cn/mini-program/json/lottie.json',
  rendererSettings: {
    context,
  },
 })
 this.inited = true
}).exec()
最后一次编辑于  2021-09-24
回答关注问题邀请回答
收藏

1 个回答

  • 闾佐
    闾佐
    2022-08-08

    遇到了同样的问题

    补充一个 windows下报错

    window.__global.createCustomImage is not a function

    TypeError: window.__global.createCustomImage is not a function

        at ut.createImage

    2022-08-08
    有用
    回复
登录 后发表内容