1. dom
<button @click="exportRaw" style="margin-top:20px">导出</button>
2.方法
exportRaw() {
const name = '文件名'
const data = JSON.stringify('111111') //console.log(数据可转成字符串)
var urlObject = window.URL || window.webkitURL || window;
var export_blob = new Blob([data]);
var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
save_link.href = urlObject.createObjectURL(export_blob);
save_link.download = name;
this.fakeClick(save_link);
},
fakeClick(obj) {
var ev = document.createEvent('MouseEvents');
ev.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
obj.dispatchEvent(ev);
}