收藏
回答

createSelectorQuery调用报错?

为什么在模拟器上可以实现动画显示,整机调试就报错?

回答关注问题邀请回答
收藏

1 个回答

  • Cjiang
    Cjiang
    2020-11-20

    你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

    2020-11-20
    有用
    回复 2
    • I do not deserve it
      I do not deserve it
      2020-12-18
      在模拟器上是不会出现问题的 在真机调试就出现了!




       
        点我预览动画</button>



      import lottie from 'lottie-miniprogram'//引入lottie npm包
      Page({
        data: {
         
        },
        onLoad() {
          
        },
        onReady() {
          
        },
        click() {//按键点击事件
          wx.createSelectorQuery().select('#canvas').node(res => {
            const canvas = res.node
            const context = canvas.getContext('2d')
            canvas.weidth = 300//设置宽高,也可以放到wxml中的canvas标签的style中
            canvas.height = 300
            lottie.setup(canvas)//要执行动画,必须调用setup,传入canvas对象
       
            lottie.loadAnimation({//微信小程序给的接口,调用就完事了,原理不太懂
              loop: true,//是否循环播放(选填)
              autoplay: true,//是否自动播放(选填)
              path:'https://colacodeapplet.oss-cn-hangzhou.aliyuncs.com/lottie_kv.json',//lottie json包的网络链接,可以防止小程序的体积过大,要注意请求域名要添加到小程序的合法域名中
              rendererSettings:{
                context//es6语法:等同于context:context(必填)
              }       
            })
          }).exec()
        }
      })
      2020-12-18
      回复
    • Cjiang
      Cjiang
      2020-12-18回复I do not deserve it
      https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html,按照链接提供下一个复现的代码片段看看。
      2020-12-18
      回复
登录 后发表内容
问题标签