【问题标题】:what is /#/ in URL?URL 中的 /#/ 是什么?
【发布时间】:2018-06-08 17:36:37
【问题描述】:

我用vue-cli创建了一个空的Hello World项目, 在components 中添加一个HelloWorld2.vue,它基本上是从HelloWorld.vue 复制而来的。 然后像这样将新的添加到router/index.js

export default new Router({
  routes: [
    {
      path: '/',
      component: HelloWorld
    },
    {
      path: '/HelloWorld2',
      component: HelloWorld2
    }
  ]
})

问题: 当我尝试访问HelloWorld2

1. localhost/#/HelloWorld2 //right
2. localhost/HelloWorld2   //wrong, redirect to HelloWorld

/#/ 是什么意思?

【问题讨论】:

标签: url vue-router


【解决方案1】:

如果你想删除井号,你应该将mode: 'history',传递给你的路由器:

export default new Router({
  routes: [...],
  mode: 'history'
})

这将从您的网址中删除哈希 #

【讨论】:

    猜你喜欢
    • 2011-09-05
    • 1970-01-01
    • 2014-10-14
    • 2017-02-01
    • 2016-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多