【发布时间】:2020-02-11 12:14:16
【问题描述】:
我正在使用 ionic v4 和 ngx-qrcode 库来生成 qrcode。但是我还需要下载这个生成的 qrcode,但是当我点击 android 上的按钮时,ionic 不会执行任何操作。在浏览器中工作。
getImage(): void {
const canvas = document.querySelector('canvas') as HTMLCanvasElement;
const imageData = canvas.toDataURL('image/jpeg').toString();
const img = document.createElement('img');
img.src = imageData;
const a = document.createElement('a');
a.setAttribute('download', 'YourFileName.jpeg');
a.setAttribute('href', imageData);
a.appendChild(img);
a.click();
}
当我单击 html 中的下载按钮时,它仅在我在浏览器中时才有效,但在 android 中没有任何反应
【问题讨论】:
-
手机需要原生插件。看看这个链接stackoverflow.com/a/51318163/10127727
-
文件传输已被弃用。请注意,它是 ionic 的新版本,文档非常稀缺
标签: angular ionic-framework download qr-code