فهرست منبع

外网文件下载问题

cyy 7 ماه پیش
والد
کامیت
ed7a72efec
1فایلهای تغییر یافته به همراه8 افزوده شده و 0 حذف شده
  1. 8 0
      src/views/component/fileTraining/index.vue

+ 8 - 0
src/views/component/fileTraining/index.vue

@@ -635,6 +635,14 @@ export default {
             if (this.isSuper || hasRole == 1) {
                 const a = document.createElement('a')
                 a.href = this.optionFile.url
+
+                console.log('文件下载替换前地址:',a.href)
+                const url = new URL(a.href)
+                //替换文件下载路径为浏览器路径
+                url.host = window.location.host;
+                a.href = url.href
+                console.log('文件下载替换后地址:',a.href)
+
                 a.download = this.optionFile.data.fileName
                 document.body.appendChild(a)
                 a.click()