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 }
      ]
    })
  • 相关阅读:
    集合使用技巧
    集合总结
    Eclipse快捷键大全
    集合去掉重复元素的两种方式
    Collection集合的三种遍历方式
    win基本流程
    url
    StringBuffer7
    StringBuffer8
    StringBuffer6
  • 原文地址:https://www.cnblogs.com/yiyi17/p/8404090.html
Copyright © 2011-2022 走看看