若依框架前端部署子目录修改内容

1、修改vue.config.js

publicPath: process.env.NODE_ENV === "production" ? "/dist/" : "/dist/",

2、修改router目录下index.js

## 这段new Router本来就有,需要增加 base: '/dist'
export default new Router({
  base: '/dist', //如果项目部署在子目录,则需要在这里配置子目录路径
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

3、/index 路由添加获取子路径 /dist

修改 layout/components/Navbar.vue 中的 location.href,

location.href = '/dist/index';

修改 utils/request.js 中的 location.href

location.href = '/dist/index';

4、修改 nginx 配置

location /dist {
	root   /home/ruoyi/projects/ruoyi-ui;
	try_files $uri $uri/ /index.html;
	index  index.html index.htm;
}

你可能感兴趣的:(VUE,前端)