javascript - Using axios to request a local json file in vue2.0, the result is a 404 error. I have tried many methods and still get the error. Beginners, please give me some advice.
我想大声告诉你
我想大声告诉你 2017-05-19 10:31:07
0
5
1769

This is the vue page

This is the project structure

result

The configuration added by index.js under config

The modified path in the axios configuration file

Everything is wrong no matter how I set the path. I just can’t find this json file. I hope someone can give me some advice. Thank you

我想大声告诉你
我想大声告诉你

reply all(5)
迷茫

Put the home.json file in the /static/ directory, and then

axios.get('http://localhost:8080/static/home.json')
某草草

Just fill in the domain name for target in proxy. Come and thank me

Peter_Zhu
你这是访问服务器文件,应该把json文件放在最外层的static文件夹,这个文件夹是vue-cli内置服务器向外暴露的静态文件夹
给我你的怀抱

It seems that axios requests http, so the json file I created myself cannot be accessed? I don’t understand a bit

为情所困

Modify the local dev-server.js... just parse it into static resources...

For example, put your json in the /example folder and modify express as follows~

build/dev-server.js

app.use('/example', express.static('./example'))
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template