vue-router模式为history的项目打包发布后不能通过地址栏里的地址进行路由跳转

参考 https://blog.csdn.net/u011025083/article/details/80352301

 

https://blog.csdn.net/nianqusuifeng/article/details/88531872

 

server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
try_files $uri $uri/ /index.html;#必须要有的
root /home/dist/;#打包后的项目路径,index.html所在文件夹
index index.html index.htm;
}
}

 

Vue的history配置到Tomcat,需要在部署同级目录添加 /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>

参考 https://blog.csdn.net/elisunli/article/details/79823245

posted on 2019-12-16 16:56  ${}  阅读(2058)  评论(0编辑  收藏  举报

导航