Vue-cli packing problem

all the packaged files can be used by css, that is, the json file 404 in static has been modified once on the Internet, but it still can"t be displayed.

  build: {
    // Template for index.html
    index: path.resolve(__dirname, "../dist/index.html"),

    // Paths
    assetsRoot: path.resolve(__dirname, "../dist"),
    assetsSubDirectory: "static",
    assetsPublicPath: "./",

this is how I refer to the local json file:

  mounted: function () {
    axios.get("static/data/dataBase.json")
      .then((res) => {
        console.log(res)
        this.news = res.data.dataTxt
      })
      .catch((err) => {
        console.log(err)
      })
  },
Mar.22,2021

put

  assetsPublicPath: './',
Change

to

  assetsPublicPath: '/',

try


agree with @ xiaofei's answer

this is a common problem in vue.

therefore, I suggest you check it out

assetsRoot: path.resolve(__dirname, '../dist'), // 
assetsSubDirectory: 'static', // html
assetsPublicPath: './', //  '/' 

    
    
    



I quote the answer on the Internet here, you can refer to it.

The reference prefix of
assetsPublicPath, a static resource, defaults to /

according to the above configuration, when you put the files under the dist folder on the server,

can use http://www.xxx.com/static/js/. then assetsPublicPath does not need to be modified
requires http://www.xxx.com/aaa/bbb/st.
, then assetsPublicPath has to be changed to / aaa/bbb/, and then build again, uploaded to the server when you upload the static file to cdn,.
needs to use http://stacic.yyy.com/aaa/bbb.
, then assetsPublicPath has to be changed to http://stacic.yyy.com/aaa/bbb/, and then build again.
uploading to the server with an absolute path sounds complicated. Can I use a relative path? Of course, it is also possible, but the configuration is much more complicated than using absolute paths, which mainly involves pictures and fonts in
css files

.

first, assetsSubDirectory should be set to empty and change assetsPublicPath, to. / modify new
ExtractTextPlugin (utils.assetsPath ('css/ [name]. [contenthash] .css')),
to new ExtractTextPlugin ('[name]. [contenthash] .css')

quoted from- https://www.mmxiaowu.com/arti.

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-1eb0ebb-2312.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-1eb0ebb-2312.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?