Vue Router去掉url中默认的锚点#

小编推荐:Fundebug提供JS错误监控、微信小程序错误监控、微信小游戏错误监控,Node.j错误监控和Java错误监控。真的是一个很好用的错误监控费服务,众多大佬公司都在使用。

hash模式url

vue-router默认hash模式——使用URL的hash来模拟一个完整的URL,于是当URL改变时,页面不会重新加载。

如果不想要这种默认的hash模式,可以用路由的history模式,这种模式充分的利用history.pushState API来完成URL跳转而无需重新加载页面。

index.js

Vue.use(Router)
export default new Router({
 mode: 'history',
 routes: [
 {
  path:"/xxx",
  name:"xxx",
  component: Xxx,
 }
]
})

history模式

修改之后url就变成了正常的url



作者:易水人去丶明月如霜
链接:https://www.jianshu.com/p/d42956600ed1

猜你喜欢

转载自blog.csdn.net/qq_40126542/article/details/89668267