<div @click="exl()">1111111111</div>
methods: {
exl() {
var img =
"http://n.sinaimg.cn/photo/transform/600/w300h300/20200527/681a-iufmpmn0346660.jpg";
const url = img;
// window.open(_this.detail.imgUrl)
let xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", url, true);
xmlhttp.responseType = "blob";
xmlhttp.onload = function () {
if (this.status == 200) {
const blob = this.response;
const link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
// link.download = url.substring(url.lastIndexOf("/") + 1, url.length);
link.download =
"图片." + url.substring(url.lastIndexOf(".") + 1, url.length);
//此写法兼容可火狐浏览器
document.body.appendChild(link);
const evt
vue图片文件下载
最新推荐文章于 2024-07-09 15:15:21 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)