php - 求助:vue.router的history用法

 MINT米田 发布于 2022-11-30 22:19

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#! 。

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

    2022-11-30 22:34 回答
  • history.pushstate 自己写进去?

    2022-11-30 22:34 回答
  • 都开了history模式为什么还要这个#!呢?

    2022-11-30 22:34 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有