vue 解决附件跨域下载文件名乱码问题


//解决附件跨域下载文件名乱码问题
exports.install = function (Vue, options) {
  Vue.prototype.fileDownload  = function (url, fileName) {
    var x = new XMLHttpRequest();
    x.open('GET', url, true);
    x.responseType = 'blob';
    x.onload = function(e) {
        var url = window.URL.createObjectURL(x.response)
        var a = document.createElement('a');
        a.href = url
        a.download = fileName;
        a.click()
    }
    x.send()
   };
};
vue