0
我正在使用Vuejs應用程序。基於類星體框架,在SRC /組件/ Hello.vue 有我有一個函數來加載JSON文件VueJs本地資產路徑
axios.get('../assets/json/ar/myfile.json')
.then(response => {
// JSON responses are automatically parsed.
console.log(response)
})
.catch(e => {
this.errors.push(e)
})
返回錯誤,GET http://localhost:8080/assets/json/ar/ch78.json 404 (Not Found)
所以我的問題是如何從src中的文件/資產文件夾? axios.get('../assets/json/ar/myfile.json')
這一行需要加以糾正
我期待你的src目錄通過您的Web服務器的調用是不能直接使用。 Vue使用什麼構建工具? –
你可以使用'import'作爲靜態資產。 – CENT1PEDE
看到爲什麼我不使用導入這裏..https://stackoverflow.com/questions/46430911/simplest-method-for-copying-all-objects-into-array?noredirect = 1#comment79819723_46430911 – rashidnk