求助:vue.router的history用法

let router = new VueRouter({
hashbang: true,
history: true,
saveScrollPosition: true,
transitionOnLoad: true
})
之所以开启vue-router的history,我是觉得能方便使用它的定位功能,就是从详细页面返回列表页面能自动定位。
但随之带来了刷新问题。
不使用history,url格式为http://xxx.xxx.xxx/index#!goodslist
使用history后,url格式为http://xxx.xxx.xxx/goodslist
请问,使用history如何能给我每一个url地址自动添加/index#! 。

阅读 8.7k
3 个回答

前端路由模式有两种 一种是 hash 模式,使用 # 导航。另一种是 Html5HistoryAPI 模式,不使用 #。
你开启了 history 就是使用 Html5HistoryAPI 模式,使用这个模式不会添加 #

history.pushstate 自己写进去?

都开了history模式为什么还要这个#!呢?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题