美文网首页uni
小程序canvas阻止跟随页面滑动

小程序canvas阻止跟随页面滑动

作者: litielongxx | 来源:发表于2022-02-14 10:16 被阅读0次

页面canvas随长页面滑动,css设置好似失效时。
一般多为父元素使用了position之类,其余的少见看详情。
重写下样式和布局即可。


image.png
解决:把canvas生成后换成image展示

bug触发几率看链接1,其余看链接2

ctx.draw(true, function () {
      wx.canvasToTempFilePath({
        canvasId: "myCanvas",
        success(res) {
          console.log('myCanvasr',res);
          if (res.tempFilePath) {
            self.setData({
              showCanvaImg: true,
              canvasImgUrl: res.tempFilePath,
            });
          }
          console.log('替换图片',res.tempFilePath)
        },
        fail(err) {
          console.log('绘图失败',err)
        }
      });
    });
...
<canvas wx:if="{{!showCanvaImg}}"  id="myCanvas" ></canvas>
<image wx:else class="fin-char" src="{{canvasImgUrl}}"></image>

ps:
https://developers.weixin.qq.com/community/develop/doc/07f5948feb7ebbfb46c3b63a1206e298
https://blog.csdn.net/xd_yangxiaoromg/article/details/88258744

相关文章

网友评论

    本文标题:小程序canvas阻止跟随页面滑动

    本文链接:https://www.haomeiwen.com/subject/rjsclrtx.html