<sp-html2canvas-render domId="htmlCanvas" @renderOver="renderOver">
<view id="htmlCanvas" class="picture" ref="imgCanvas">
<view style="padding-top: 750rpx;margin-left:80rpx;">
<view style="display:inline; float:left; width:350rpx;">
<p style="font-size:30rpx;font-weight: bold;">{{orgName}}</p>
<p style="font-size:25rpx;margin-top:10rpx; ">wwwwww</p>
</view>
<view style="display:inline;float:left;">
<uqrcode ref="uqrcode" canvas-id="qrcode" :value="copyUrl" :size="90" :options="{
foregroundImageSrc:'/static/madian/qrcodeLogo.png'
}">;
</uqrcode>
</view>
</view>
</view>
</sp-html2canvas-render>
这是要导出的模块,h5可以正常输出base64,app真机调试报错Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported. at uni_modules/sp-html2canvas-render/components/sp-html2canvas-render/sp-html2canvas-render.vue:24 at app-view.js:40613
8 个回复
夏夜追凉丶
经过实测,sp-html2canvas-render中可正常嵌套组件或者canvas,请问你的uqrcode组件中是怎么写的
夏夜追凉丶
还有,请问一下你的项目是vue2还是vue3
夏夜追凉丶
canvas绘制图片,由于浏览器的安全考虑,如果在使用canvas绘图的过程中,使用到了外域的图片资源,那么在toDataURL()时会抛出安全异常:Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
夏夜追凉丶
所以可能需要先排除uqrcode组件中是否使用canvas绘制二维码的时候出了问题
9***@qq.com (作者)
使用的都是项目static的图片,使用的项目是vue3,uqrcode为uniapp的插件,我没有进行操作,只是配置路径http://111.11.1.111:11035?urlId=S7L4U88/QkbYyEq4 以及二维码的样式,我先排除下这个uqrcode组件
9***@qq.com (作者)
将uqrcode 组件注释掉之后,还是会报一样的错误,并且在项目启动的时候,会报错[Vue warn]: Property or method "h2cRender" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
found in
---> <SpHtml2canvasRender> at uni_modules/sp-html2canvas-render/components/sp-html2canvas-render/sp-html2canvas-render.vue:1
9***@qq.com (作者)
找到问题的所在了,需要导出的view,在class中配置了background: url('/static/nnnn/nnnn.png') no-repeat;导致导出失败
2***@qq.com
Vvvvbbbb ggggg vbwedfggggg空空空空没有开门营业执照总经理可怜巴巴记录天空买hsuoVvvvbbbb ggggg vbwedfggggg空空空空没有开门营业执照总经理可怜巴巴记录天空买hsuoVvvvbbbb ggggg vbwedfggggg空空空空没有