1.设置router跟路径
const router = createRouter({
history: createWebHistory('xxx'),
......
2.打包部署时修改根文件目录
修改为xxx
3.打包部署时在根目录下添加WEB-INF
在WEB-INF下添加web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1" metadata-complete="true">
<display-name>Router for Tomcat</display-name>
<error-page>
<error-code>404</error-code>
<location>/index.html</location>
</error-page>
</web-app>4.调整nginx配置
后端项目转发目前增加/xxx