访问/hybrid/html/index.html?
+++++++++++++++++++++++++++++++++++++++++
<view class="" v-if="srcUrl">
<web-view :src="srcUrl"></web-view>
</view>
+++++++++++++++++++++++++++++++++++++++++
var dom = document.getElementById("#app");
html2canvas(dom, {
allowTaint: true,
useCORS: true,
logging: true
}).then((canvas) => {
console.log('canvas=>', canvas)
if (canvas) {
const capture = canvas.toDataURL("image/png");
===============================================
报错 Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
- 发布:2024-10-28 12:08
- 更新:2024-10-28 12:11
- 阅读:110
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win
HBuilderX类型: 正式
HBuilderX版本号: 4.29
手机系统: Android
手机系统版本号: Android 13
手机厂商: 小米
手机机型: note 9 Pro
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
操作步骤:
预期结果:
toDataURL方法能够正常执行
toDataURL方法能够正常执行
实际结果:
···
addhtml() {
let that = this;
that.show6 = false
// let base64 = screenshot();
// console.log('base64=>', base64)
console.log('11111111111111111111111111')
var dom = document.getElementById("#app");
html2canvas(dom, {
allowTaint: true,
useCORS: true,
logging: true
}).then((canvas) => {
document.body.appendChild(canvas);
console.log('canvas=>', canvas)
if (canvas) {
const capture = canvas.toDataURL("image/png");
const base64 = capture.replace(/^data:image\/\w+;base64,/, '');
const binaryString = window.atob(base64);
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
const blob = new Blob([bytes], {
type: 'image/png'
});
}
})
},
···
···
addhtml() {
let that = this;
that.show6 = false
// let base64 = screenshot();
// console.log('base64=>', base64)
console.log('11111111111111111111111111')
var dom = document.getElementById("#app");
html2canvas(dom, {
allowTaint: true,
useCORS: true,
logging: true
}).then((canvas) => {
document.body.appendChild(canvas);
console.log('canvas=>', canvas)
if (canvas) {
const capture = canvas.toDataURL("image/png");
const base64 = capture.replace(/^data:image\/\w+;base64,/, '');
const binaryString = window.atob(base64);
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
const blob = new Blob([bytes], {
type: 'image/png'
});
}
})
},
···
bug描述:
<view class="" v-if="srcUrl">
<web-view :src="srcUrl"></web-view>
</view>
+++++++++++++++++++++++++++++++++++++++++
var dom = document.getElementById("#app");
html2canvas(dom, {
allowTaint: true,
useCORS: true,
logging: true
}).then((canvas) => {
console.log('canvas=>', canvas)
if (canvas) {
const capture = canvas.toDataURL("image/png");
===============================================
报错 Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
1 个回复
1***@qq.com (作者)
uniapp 安卓App 视频路径是rtmp路径 video层级太高 我用cover-view和cover-image解决 但是背景图和有些定位元素不支持 自定义弹出框不显示
气的我用原生html加css 用uniapp web-view 去访问本地html 又加截图我原生插件html2canvas但是在手机在访问本地网页canvas.toDataURL方法不支持
只能在uniapp 里使用 我都服了uniapp