[Vue3] Solve the resource path loading error after Vue is packaged and uploaded to the server

Problem:
After packaging Vue, I upload the

packaged dist to a subdirectory named "adminstore" in the root directory of the server site. ,
But when I opened the site through the domain name, I found that the resource loading path did not contain the subdirectory "adminstore" file name
Error: http://your website domain/js/app.5738021f.js 
Correct: http://your website domain/adminstore/js/app.5738021f.js
 

 

Reason: In the Vue project, if the packaged file is placed in a subdirectory of the site root directory, but the resource search path is based on the site root directory, resource loading errors may occur.

Solution:
Use the "publicPath
" attribute in the "vue.config.js" file of the Vue project to tell him to package your Subdirectory file name

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  publicPath: '/adminstore/'
})

Guess you like

Origin blog.csdn.net/m0_64494670/article/details/134586964