浏览器下载图片

310 阅读1分钟
//生成二维码
<div id="qrcode"></div>
<button @click="downloadCodeImg()">下载</button>

downloadCodeImg() {
    var alink = document.createElement("a");
    alink.href = document.querySelector('#qrcode img').src;//base64格式的图片
    alink.download = "qitushequ"; //图片名
    alink.click();
},