目录
路由History模式打包页面空白
项目放根目录 -- 配置
项目放二级目录 -- 配置
路由History模式打包页面空白
项目放根目录 -- 配置
router => index.js
修改 base
const router = new VueRouter({
mode: 'history',
// base: process.env.BASE_URL,
base: '/',
routes,
})
nginx.conf 配置
server {
listen 80;
server_name localhost;
location / {
alias F:/erp/dist/;
try_files $uri $uri/ /index.html;
}
}
改完重启 nginx
项目放二级目录 -- 配置
router => index.js
修改 base
const router = new VueRouter({
mode: 'history',
// base: process.env.BASE_URL,
base: '/erp_project',
routes,
})
nginx.conf 配置
/erp_project 与上面 base 一致
server {
listen 80;
server_name localhost;
location /erp_project {
alias F:/erp/dist;
index index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.*) /erp_project/index.html last;
break;
}
}
}
改完重启 nginx
参考:https://www.jb51.net/article/142831.htm