// content 為接口傳回來(lái)的值 "\ufeff"是為了解決CSV中文亂碼問題
const blob = new Blob(["\ufeff" + content], {
type: 'text/csv;charset=utf-8;'
});
// 如果是 IE 瀏覽器
if (window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, 'name.csv');
} else {
const link = document.createElement('a');
const url = URL.createObjectURL(blob);
link.href = url;
link.setAttribute('download', 'name.csv');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者