VUE-CLI Project gets local JSON file data __js

Source: Internet
Author: User

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

    Axios.get (' Http://localhost:8080/datas/json ')

In this process, however, My visit is always 404. Through the lookup, I found that in the project built on the basis of VUE-CLI, only the static directory is vue-cli outward exposed static data folder, I put the static picture can be normal access to, I was in the static sibling directory created a new datas directory, the JSON file Put in the Datas directory, the request is always 404, when I put the JSON file in the static directory, you can access the normal. This feature must be remembered:

    The static directory is VUE-CLI exposed, and all static data should be placed in the static directory ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.