this.timer = setTimeout(() => {
uni.canvasToTempFilePath(
{
canvasId: 'my-canvas',
quality: 1,
complete: res => {
console.log(res);
uni.hideLoading();
if(res.tempFilePath){
this.canvasImg = res.tempFilePath;
this.$refs['popup'].open();
}else{
}
},
fail: err => {
}
},
this
);
}, 500);
- 发布:2020-11-30 17:27
- 更新:2020-11-30 17:32
- 阅读:536
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 2.9.8
手机系统: Android
手机系统版本号: Android 10
手机厂商: 华为
手机机型: mate30 pro
页面类型: vue
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
this.timer = setTimeout(() => {
uni.canvasToTempFilePath(
{
canvasId: 'my-canvas',
quality: 1,
complete: res => {
console.log(res);
uni.hideLoading();
if(res.tempFilePath){
this.canvasImg = res.tempFilePath;
this.$refs['popup'].open();
}else{
}
},
fail: err => {
}
},
this
);
}, 500);
this.timer = setTimeout(() => {
uni.canvasToTempFilePath(
{
canvasId: 'my-canvas',
quality: 1,
complete: res => {
console.log(res);
uni.hideLoading();
if(res.tempFilePath){
this.canvasImg = res.tempFilePath;
this.$refs['popup'].open();
}else{
}
},
fail: err => {
}
},
this
);
}, 500);
预期结果:
1
1
实际结果:
canvasToTempFilePath:fail SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported
canvasToTempFilePath:fail SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported
bug描述:
【华为mate30 pro】 uni.canvasToTempFilePath报错canvasToTempFilePath:fail SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported
其他手机能正常
1 个回复
DCloud_UNI_LXH
报错的意思是图片跨域