收藏
回答

TypeError: r.Canvas is not a constructor ?


canvas画布, 开发工具不报错,真机调试就出现错误: Unhandled promise rejection TypeError: r.Canvas is not a constructor

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

10 个回答

  • 杭永胜
    杭永胜
    2020-11-06

    一年过去了,真机调试依然不支持canvas 2d,求提升优先级

    2020-11-06
    有用 2
    回复 8
    • 国家一级废物
      国家一级废物
      发表于移动端
      2021-04-27
      回去。
      2021-04-27
      回复
    • Jensen     0o0
      Jensen 0o0
      2021-05-16
      今天还不支持!
      2021-05-16
      回复
    • tu
      tu
      2021-11-10
      2021年11月,还是报错……
      2021-11-10
      1
      回复
    • 阳光灿烂
      阳光灿烂
      2021-11-12
      不支持真机调试,那只能模拟器查效果,内测都看不了?
      2021-11-12
      回复
    • Hmlyn丶
      Hmlyn丶
      2022-10-01
      2022年了
      2022-10-01
      回复
    查看更多(3)
  • 巡山咯
    巡山咯
    2022-01-06

    两年了

    2022-01-06
    有用
    回复
  • 胖虎
    胖虎
    2021-11-29

    现在是2021年11月29日,此bug 还是没有修复

    2021-11-29
    有用
    回复 3
    • 👻
      👻
      2021-12-24
      2021-12-24,此bug 还是没有修复
      2021-12-24
      回复
    • 君无young
      君无young
      2021-12-30
      2021-12-30
      2021-12-30
      回复
    • 杨哈哈哈哈哈哈哈哈哈
      杨哈哈哈哈哈哈哈哈哈
      2022-01-04
      2022-1-4 此bug 还是没有修复
      2022-01-04
      1
      回复
  • ゛小云宝へ゛
    ゛小云宝へ゛
    2021-04-10

    现在还不支持真机调试嘛?不支持的话,我就忽略这个问题了。。。

    2021-04-10
    有用
    回复
  • 九幽天决
    九幽天决
    2020-09-11

    问题解决了嘛 我也有这个问题

    2020-09-11
    有用
    回复 1
    • Han
      Han
      2020-09-11
      真机调试本身不支持canvas, 不是问题
      2020-09-11
      回复
  • 韦不吕
    韦不吕
    2020-05-14

    ‘真机调试’有这个问题;手机预览调试没有。

    2020-05-14
    有用
    回复
  • 陈建斌
    陈建斌
    2020-04-14

    此问题大家都解决了吗?我这里是用canvas 2d在iPad上报错,如果是用webgl就没有问题。真机调试报错如下:

    runtime.js?devtools_ignore=true:1 [Violation] 'message' handler took 258ms

    VM14:2 Unhandled promise rejection TypeError: r.Canvas is not a constructor

        at n.value (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:742386)

        at n.value (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:626107)

        at t (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:626279)

        at n.value (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:626368)

        at eval (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:1244118)

        at new T (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:66743)

        at t (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:1244080)

        at eval (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:1244135)

        at Array.forEach (<anonymous>)

        at r (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:1243340)

    eval @ VM14:2

    e.exports @ VM14:2

    eval @ VM14:2

    e.exports @ VM14:2

    y.<computed> @ VM14:2

    r @ VM14:2

    eval @ VM14:2

    eval @ VM14:2

    eval @ VM14:2

    setTimeout (async)

    setTimeout @ VM14:2

    _.now.f.addEventListener.f.importScripts.i @ VM14:2

    h @ VM14:2

    M @ VM14:2

    eval @ VM14:2

    e @ VM14:2

    e.exports @ VM14:2

    y.<computed> @ VM14:2

    r @ VM14:2

    eval @ VM14:2

    eval @ VM14:2

    eval @ VM14:2

    setTimeout (async)

    setTimeout @ VM14:2

    _.now.f.addEventListener.f.importScripts.i @ VM14:2

    h @ VM14:2

    o @ VM14:2

    eval @ VM14:2

    D @ VM14:2

    B @ VM14:2

    eval @ VM14:2

    success @ VM14:2

    eval @ VM14:2

    y @ VM14:2

    v @ VM14:2

    eval @ VM14:2

    v @ VM14:2

    u @ runtime.js?devtools_ignore=true:1

    w @ runtime.js?devtools_ignore=true:1

    ke.onmessage @ runtime.js?devtools_ignore=true:1

    2020-04-14
    有用
    回复 2
    • Han
      Han
      2020-04-14
      canvas 2D 不支持真机调试
      2020-04-14
      回复
    • 陈建斌
      陈建斌
      2020-04-14回复Han
      谢谢,关键是正式版本在iPad上不行啊,只能想着真机测试,但是在iPhone和Android手机上是好的,怎么搞呢?
      2020-04-14
      回复
  • M
    M
    2020-04-09

    请问楼主解决了吗,我开发者工具正常,真机调试报这个错,预览闪退

    2020-04-09
    有用
    回复 1
    • Han
      Han
      2020-04-14
      canvas 2D 不支持真机调试
      2020-04-14
      回复
  • 任小超
    任小超
    2020-03-15

    请问楼主解决这个问题了吗?开发者工具正常,真机预览、调试都报这个错误

    2020-03-15
    有用
    回复 12
    • Han
      Han
      2020-03-16
      目前还没有真机预览, 不过你可以运行一下体验版小程序, 看看效果怎么样? 体验结果可以给我说一下。
      2020-03-16
      回复
    • 任小超
      任小超
      2020-03-16回复Han
      体验版应该也是一个问题,因为我有个组件就是canvas的动画,在体验版上用手机就没有渲染出来,应该就是报错了,手机上打开调试就正常,关了就不行
      2020-03-16
      回复
    • 任小超
      任小超
      2020-03-16回复Han
      你碰到的问题在手机上预览正常了吗?
      2020-03-16
      回复
    • Han
      Han
      2020-03-16
      你用的是不是canvas 新的API? 我现在的项目进度有些慢, 没有进行 手机预览
      2020-03-16
      回复
    • 任小超
      任小超
      2020-03-16回复Han
      我用的lottie-miniprogram 开发lottie动画
      2020-03-16
      回复
    查看更多(7)
  • 灵芝
    灵芝
    2019-10-31

    是哪个版本的开发工具?

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

    2019-10-31
    有用
    回复 10
    • Han
      Han
      2019-10-31
      开发工具版本号:1.02.1910120;微信版本号:7.0.8 系统:ios13.1.1
      2019-10-31
      回复
    • 灵芝
      灵芝
      2019-10-31回复Han
      麻烦提供一下代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html
      2019-10-31
      回复
    • Han
      Han
      2019-11-04
      //初始化canvas
        init(res) {
          const width = res[0].width
          const height = res[0].height
          const canvas = res[0].node
          const ctx = canvas.getContext('2d')
          const dpr = wx.getSystemInfoSync().pixelRatio
          canvas.width = width*dpr
          canvas.height = height*dpr
          ctx.scale(dpr, dpr)
          let dot = 0;
          const renderLoop = () => {
            if(Object.keys(that.data.testingMachineData).length > 0) {
              if (that.data.testingMachineData['位移'].length > 300) {
                //console.log(that.data.testingMachineData)
                dot = that.data.testingMachineData['位移'].shift()
              }
            }
            that.render(canvas ,ctx, dot)
            canvas.requestAnimationFrame(renderLoop)
          }
          canvas.requestAnimationFrame(renderLoop)
          const stents = canvas.createImage()
          const beam = canvas.createImage()
          stents.onload = () => {
            that._stents = stents
          }
          beam.onload = () => {
            that._beam = beam
          }
          stents.src = '../../images/stents.png'
          beam.src = '../../images/beam.png'
        },
        render(canvas, ctx, dot) {
          ctx.clearRect(0, 0, 350, 350)
          that.drawStents(ctx)
          that.drawBeam(ctx, dot)
          that.drawDisplay(ctx, dot)
        },
        drawStents(ctx) {
          if (!that._stents) return
          ctx.drawImage(that._stents, 50, 0, 180, 200)
          ctx.restore()
        },
        drawBeam(ctx, dot) {
          if(!that._beam) return
          if(that.y > 350) {
            that.y = -10
          }
          let transBeamDot = dot * 5 + 30
          ctx.drawImage(that._beam, 112, transBeamDot, 50, 50)
          ctx.restore()
        },
        //显示数据
        drawDisplay(ctx, dot) {
          let transBeamDot = dot * 5 + 30
          ctx.beginPath()
          ctx.moveTo(180, transBeamDot + 20)
          ctx.lineTo(240, transBeamDot + 20)
          ctx.lineTo(270, transBeamDot)
          ctx.font = "14px Times New Roman"
          if(dot == 0) {
            ctx.strokeText('0.000', 280, transBeamDot)
          }else{
            ctx.strokeText(dot, 280, transBeamDot)
          }
          ctx.stroke()
        },
      2019-11-04
      回复
    • 灵芝
      灵芝
      2019-11-05回复Han
      canvas 2d和webgl 暂不支持真机调试,请直接使用真机预览
      2019-11-05
      2
      回复
    • W
      W
      2019-11-05
      有计划支持一下吗
      2019-11-05
      1
      回复
    查看更多(5)
登录 后发表内容
问题标签