Problems with vue projects accessing static directories

I use vue-cli 3.0
I follow the tutorial to create a file static/test.json
in the static directory, but when I enter localhost:8080/static/test.json at the address, I fail to access it and jump to the home page
. I look it up on the Internet and say that the vue-cli 3.0 static file is placed under the public directory, and then I change the json file to the json file. Do you want to configure it somewhere?

directory structure

clipboard.png

Mar.23,2021

finds a problem. By default, access to static files will find public , and localhost:8080/public/mock/test.json will fail to request, so the correct way to write it is localhost:8080/mock/test.json
request code:
axios.get ('/ mock/test.json') ,


Thank you, I have not used this
you should be running under dev, right? Check to see if there is a test.json file in your compiled static directory, if not. You can copy it using the CopyWebpackPlugin plug-in. Hope to help you


vue route needs to be defined before it is effective. Access to resource files directly on url is not visible


localhost:8080 is not the root directory, oh


webpack-dev-server the files used are all data that are processed by various loader and put in the cache. Of course, you can't find the input path in the browser, but in the file, you can get it in other files through the relative path of the file.


3.0. generally speaking, if there is a problem with static or public, try calling node

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea75a0-47c23.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea75a0-47c23.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?