vue项目中每一个url都有一个"#/", 在路由的index.js 中使用history模式去掉了这个"#/",但是打包之后就访问不到index.html中的内容了, 这是怎么回事呢? 望各位大佬解答一下.
vue项目vue-router路由history模式打包后放在服务器上要在WEB-INF/web.xml文件中配置:
<error-page>
<location>/index.html</location>
<error-code>404</error-code>
</error-page>
同时项目中也要一个404页面:
部署到iis上就能访问到 或者改用hash模式
在服务端增加一个覆盖所有情况的候选资源:如果 URL 匹配不到任何静态资源,则应该返回同一个 index.html 页面,这个页面就是你 app 依赖的页面。
参考官网:https://router.vuejs.org/zh/guide/essentials/history-mode.html#%E5%90%8E%E7%AB%AF%E9%85%8D%E7%BD%AE%E4%BE%8B%E5%AD%90