让axios读取本地模拟数据报错404: Error: Request failed with status code 404

it2024-07-12  41

原因一:cli3.0已经把静态资源的文件夹改成public文件夹了,所以静态资源应该放置在public文件夹下。

但是!我这样写依旧是报错!

很难受,但是我没有哭。

原因二,访问静态文件的路径不需要public.

因为访问静态资源时,已经定位到public文件夹了!!! 于是去掉public

//获取后台数据 async getHomeInfo(){ const {data:res}=await this.$http.get('http://localhost:8080/index.json') console.log(res) }

然后刷新,啦啦啦,成功啦! 完结,撒花花!!!

最新回复(0)