<el-button size="small" @click="exportDatas(scope.row.img)" type="info" plain>下载</el-button>
exportDatas: function (img) {
var xhr = new XMLHttpRequest();
xhr.open('get', img);
xhr.responseType = 'blob';
xhr.send();
xhr.onload = function () {
if (this.status === 200 || this.status === 304) {
const fileReader = new FileReader();
fileReader.readAsDataURL(this.response);
fileReader.onload = function () {
const a = document.createElement('a');
a.style.display = 'none';
a.href = this.result;
a.download = '处方单';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
};
}
};
},