vue-cli3 public文件创建static文件保存word
axios({ method: 'get', responseType: 'blob', url: 'static/json/sm.doc' // word在static文件下 }).then(res=> { console.log(res); let blob = new Blob([res.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;"}); // 为blob设置文件类型 let url = window.URL.createObjectURL(blob); let a = document.createElement("a"); a.href = url; a.download = 'name.doc'; a.style.display='none'; document.body.appendChild(a); a.click(); a.parentNode.removeChild(a); window.URL.revokeObjectURL(url); })