[英]Not allowed to load local resource [Vue js with Axios]
我使用Axios.get獲取文件的路徑: C:\\Users\\me\\AppData\\Local\\Temp\\lorem.csv
Axios語法獲取
{
// axios post generate
const URL = '/api/report'+ '/generate'
axios.post(URL, {
report: this.editedItem.report,
values: this.editedItem.values
})
.then(response => {
this.fetchItem()
const URL = '/api/report/path'
axios.get(URL)
.then(response => {
this.path = response.data
})
.catch(err => {
alert(err)
})
})
.catch(err => {
//what happen after error
alert(err)
})
this.close()
}
然后將該路徑發送到a標簽
<a :href="path" download target="_blank" class="tabs__item tabs__item--active" style="position: relative;"><u>{{ path }}</u></a>
但是,控制台說:不允許加載本地資源:[路徑]
我嘗試過[不起作用]:-節點:__dirname:false,__filename:false-Blob類型數據-其他瀏覽器,仍然相同
該文件是動態的,服務器生成該文件並將其保存在目錄中。
您將Axios用作前端庫,這意味着它無法訪問文件系統。 Not allowed to load local resource:
這是在告訴您您正在嘗試破壞瀏覽器中的沙箱。
Axios專門用於調用api,盡管您可以在諸如Node
類的可以使用fs
類的文件系統訪問的東西上使用它,這就是為什么您仍可以在瀏覽器中嘗試使用它的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.