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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM