收藏
回答

canvas.toDataURL() 方法在IOS 中返回值为字符串“data:,?

在安卓系统中正常运行  canvas.toDataURL() 方法在iphone11 pro 中返回值为字符串“data:,” 下面代码中end()方法中无法转canvas为 二进制base64



methods: {  
    init(res) {
      const width = res[0].width
      const height = res[0].height
      canvas = res[0].node
      //获得Canvas的上下文
      context = canvas.getContext('2d')
      dpr = wx.getSystemInfoSync().pixelRatio
      canvas.width = width * dpr
      canvas.height = height * dpr
      context.scale(dpr, dpr)
      context.strokeStyle = "#000";
      context.lineWidth = 3;
      //设置线两端端点样式更加圆润
      context.lineCap = 'round';
      context.lineJoin = 'round';
      context.fillStyle = "#ffffff"
      context.fillRect(0, 0, canvas.width, canvas.height);
    },
     // 画布的触摸移动结束手势响应
    end: function (e) {
      console.log("触摸结束", e);
      //清空轨迹数组
      for (let i = 0; i < touchs.length; i++) {
        touchs.pop();
      }
      // 保存当前绘图数据到数组中,撤销的时候能用得上
      if(imgList.length>=10){
        imgList.pop()
      }
      if(this.data.isdraw) {
        imgList.push(canvas.toDataURL());
      }
      if(imgList.length >=1) {
        this.setData({ disableSign: false });
        this.data.isdraw = false;
      }
    },
};
回答关注问题邀请回答
收藏

5 个回答

  • 小程序技术专员-binnie
    小程序技术专员-binnie
    2021-01-06

    ios 7.0.21发布了,修复了canvas的问题,麻烦试试看~

    2021-01-06
    有用 1
    回复 4
    • 灏达
      灏达
      发表于移动端
      2021-01-07
      Webgl的还是空吧
      2021-01-07
      回复
    • 灏达
      灏达
      发表于移动端
      2021-01-07
      什么时候修复webgl的
      2021-01-07
      回复
    • 400L
      400L
      2021-01-08
      👌
      2021-01-08
      回复
    • 黄坤
      黄坤
      2021-01-19
      现在用readPixel卡的有点过分
      2021-01-19
      回复
  • 黄黎
    黄黎
    2022-01-27

    图片过大引起的:https://segmentfault.com/q/1010000021607184

    2022-01-27
    有用 1
    回复
  • candy
    candy
    2021-12-16

    有解决的方法吗?我测了还是一样不可以哒

    2021-12-16
    有用
    回复
  • 🔥🔥🔥
    🔥🔥🔥
    2021-12-15

    webGL的什么时候修好?

    2021-12-15
    有用
    回复
  • 丹丹
    丹丹
    2021-01-27

    webgl 修复了吗?除了这个方法,你们都怎么解决的呀

    2021-01-27
    有用
    回复
登录 后发表内容
问题标签