Vue路由器链接上的英镑符号

时间:2018-08-07 03:00:03

标签: vue.js

嗨,我该如何删除Vue中路由器链接中的井号。在每个链接中,我总是会得到一个井号,例如:http://localhost:8080/#/

export default new Router({
  routes: [
    {
      path: '/',
      name: 'SplashScreen',
      component: SplashScreen
    },
    {
      path: '/aboutus',
      name: 'AboutUs',
      component: AboutUs
    },
    {
      path: '/aboutus',
      name: 'Dashboard',
      component: Dashboard
    }
  ]
})

1 个答案:

答案 0 :(得分:3)

将模式用作history

 const router = new VueRouter({
   mode: 'history',
   routes: [...]
 })

还需要服务器配置Apache

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

查看更多详细信息here