官网文档:前端手册 | RuoYi
步骤如下:有些特殊情况需要部署到子路径下,例如:
https://www.ruoyi.vip/admin
,可以按照下面流程修改。
1.步骤
1.1.修改vue.config.js中的publicPath属性
publicPath: process.env.NODE_ENV === "production" ? "/admin/" : "/admin/",
1.2.修改router/index.js,添加一行base属性
export default new Router({
base: "/admin",
mode: 'history', // 去掉url中的#
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes
})
1.3./index路由添加获取子路径/admin
修改layout/components/Navbar.vue
中的location.href
location.href = '/admin/index';
修改utils/request.js
中的location.href
location.href = '/admin/index';
1.4.修改nginx配置
location /admin {
alias /home/ruoyi/projects/ruoyi-ui;
try_files $uri $uri/ /admin/index.html;
index index.html index.htm;
}
打开浏览器,输入:https://www.ruoyi.vip/admin
能正常访问和刷新表示成功。
2. 修改
2.1.Nginx配置
2.2.生产API接口配置
2.3.vue.config.js配置
2.4.router/index.js配置
2.5.layout/components/Navbar.vue和utils/request.js配置
文章来源:https://www.toymoban.com/news/detail-756986.html
文章来源地址https://www.toymoban.com/news/detail-756986.html
到了这里,关于ruoyi vue部署服务器,点击刷新、登录主页、退出报404和nginx问题解决的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!