# 应用路径
有些特殊情况需要部署到子路径下,可以按照下面流程修改。
1、修改vue.config.js中的publicPath属性
publicPath: process.env.NODE_ENV === "production" ? "/admin/" : "/admin/",
2、修改router/index.js,添加一行base属性
export default new Router({
base: '/admin',
mode: 'history', // 去掉url中的#
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes
})
3、修改layout/components/Navbar.vue中的location.href
location.href = this.$router.options.base + '/index'
4、修改nginx配置
location /admin {
alias /home/ruoyi/projects/ruoyi-ui;
try_files $uri $uri/ /index.html =404;
index index.html index.htm;
}