+
80
-

uniapp和微信小程序中canvas如何隐藏并且draw不报错?

uniapp和微信小程序中canvas如何隐藏并且draw不报错?

我用canvas设置display:none;后直接报错

anvas>: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0. Error: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.


网友回复

+
0
-

设置fixed,并通过top将他排除在可视范围内即可

<view id="canvas">
<canvas style="width: 600px; height: 400px;" canvas-id="myCanvas"></canvas>
</view>

#canvas{
position: fixed;
top: -9999999999999rpx;
}
  

我知道答案,我要回答