1,检查pacjage.json文件中是否有build
Xnip2020-06-02_09-17-23.jpg
2,vue脚手架目录,config目录下index.js文件中,assetsPublicPath路径错误
assetsPublicPath: '/',
3,router开启了history模式,如果是本地打包后访问的话,是没有问题的,但是一旦部署到服务器上面,还需要在服务端进行配置修改,若没有进行相关配置,则会报错。
const routers = new VueRouter({
routes: router,
mode: 'history'
})
location / {
try_files uri/ /index.html;
}
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'statics',
assetsPublicPath: '/',
}
const routers = new VueRouter({
routes: router,
mode: 'history'
})
location / {
try_files $uri $uri/ /index.html;
}
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'statics',
assetsPublicPath: '/',
}
网友评论