需要访问的路径 http://xxxx.com/manager
vue 需要做的改动:
vue.config.js
let publicPath = '/manager/'
module.exports = {
publicPath: publicPath, // 根据你的实际情况更改这里
lintOnSave: true,
productionSourceMap: false,
}
router.js
export const createRouter = () => new VueRouter({
mode: 'history',
base: 'manager',
routes: [...PageRouter, ...ViewsRouter]
})
nginx 配置
location /manager {
alias d://ihsp/dist; # 二级目录只能用alias
try_files $uri $uri/ /manager/index.html; # 保障刷新后页面正常
index index.html index.htm;
}