zoukankan      html  css  js  c++  java
  • Vue之八 HTML5 History模式

    nginx配置

    location / {
      root /webroot/www/ShopMall3; try_files $uri $uri/ /index.html; }

      /:访问路径;

      root:服务器文件路径

      你要在服务端增加一个覆盖所有情况的候选资源:如果 URL 匹配不到任何静态资源,则应该返回同一个 index.html 页面,这个页面就是你 app 依赖的页面。

     

    警告

    给个警告,因为这么做以后,你的服务器就不再返回 404 错误页面,因为对于所有路径都会返回 index.html 文件。为了避免这种情况,你应该在 Vue 应用里面覆盖所有的路由情况,然后在给出一个 404 页面。

    const router = new VueRouter({
      mode: 'history',
      routes: [
        { path: '*', component: NotFoundComponent }
      ]
    })
  • 相关阅读:
    第三周课程总结
    Java第一次学习总结
    第十二周编程总结
    第九周作业
    第八周作业
    第五周编程总结
    第三周作业
    第二周编程总结
    JAVA第二周学习总结
    2019春总结作业
  • 原文地址:https://www.cnblogs.com/yiyi17/p/8404090.html
Copyright © 2011-2022 走看看