SoFunction
Updated on 2025-04-04

Vue-cli project gets an instance of local json file data

In my own vue demo project, I want to add some json data locally, write it to a json file, and get it through an asynchronous request, and then load the data.

('http://localhost:8080/datas/json')

However, in this process, my access is always 404. Through searching, I found that in the project built on vue-cli, only the static directory is the static data folder exposed to vue-cli. The image I placed under static can be accessed normally. I created a new data directory in the static directory and put the json file into the data directory. The request is always 404. When I put the json file in the static directory, I can access it normally.

This feature must be remembered:

The static directory is a static folder exposed by vue-cli, and all static data should be placed in the static directory! !

The above example of obtaining local json file data from the Vue-cli project is all the content I share with you. I hope you can give you a reference and I hope you can support me more.