浏览代码

下载 txt 乱码

Michael Wang 4 年之前
父节点
当前提交
34b1353e9f
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/utils/utils.js

+ 1 - 1
src/utils/utils.js

@@ -56,7 +56,7 @@ function toDataURL(url) {
 export async function downloadFileURL(url, name) {
   const link = document.createElement("a");
   link.style.display = "none";
-  const fileName = name || url.split("/").pop();
+  const fileName = name || url.split("/").pop().split("?")[0];
   link.setAttribute("download", fileName);
 
   // txt 文件会直接在浏览器里面打开,这时候只能修改服务器设置,加上 Content-Disposition: attachment