Explorar el Código

下载 txt 乱码

Michael Wang hace 4 años
padre
commit
34b1353e9f
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  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