vue-router在ie9及以下history模式支持
参考:
https://www.npmjs.com/package/vue-route
https://github.com/devote/HTML5-History-API
提要:
ie9及以下不支持html5 history新特性
解决:
- npm install html5-history-api
- <!--[if lte IE 9]><script src=“path_to_history.js"></script><![endif]-->
- issus
history.js- IE8+ and other browsershistory.ielte7.js- IE6+ and other browsers- 使用webpack时
1 var supportsPushState = inBrowser && (function () {
2 var ua = window.navigator.userAgent;
3
4 if (
5 (ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
6 ua.indexOf('Mobile Safari') !== -1 &&
7 ua.indexOf('Chrome') === -1 &&
8 ua.indexOf('Windows Phone') === -1
9 ) {
10 return false
11 }
12
13 return window.history && 'pushState' in window.history
14 })();这里supportsPushState在加载时已经被定义,就算在之后的 require('html5-history-api') 也是没有意义的,缓存虽然是王道可有时用不好真的是个坑。。。。
var VueRouter = function VueRouter (options) {
if ( options === void 0 ) options = {}; this.app = null;
this.apps = [];
this.options = options;
this.beforeHooks = [];
this.resolveHooks = [];
this.afterHooks = [];
this.matcher = createMatcher(options.routes || [], this); var mode = options.mode || 'hash';
this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false; //这里直接使用了定义好的supportsPushState if (this.fallback) { //最终还是使用了hash模式
mode = 'hash';
}
if (!inBrowser) {
mode = 'abstract';
}
this.mode = mode;
switch (mode) {
case 'history':
this.history = new HTML5History(this, options.base);
break
case 'hash':
this.history = new HashHistory(this, options.base, this.fallback);
break
case 'abstract':
this.history = new AbstractHistory(this, options.base);
break
default:
{
assert(false, ("invalid mode: " + mode));
}
}
};
- issus
#在设计缓存时一定要考虑到上下文的依赖,过时的缓存有啥用呢
end
vue-router在ie9及以下history模式支持的更多相关文章
- 关于vue+element对ie9的兼容el-upload不支持在IE9上传
关于vue+element对ie9的兼容el-upload不支持在IE9上传 https://lian-yue.github.io/vue-upload-component/#/zh-cn/ 解决方案 ...
- Vue history模式支持ie9
vue 路由里面的history能让浏览器显示平常一样的链接,可以去掉#这种,但是在ie9下面会强制变成hash,因为history不支持ie9自动降级,可能就会影响美感,解决:可以在路由里面添加fa ...
- vue router mode 设置"hash"与"history"的区别
router官网的说明如下: ********************************************我是官网说明分隔符--开始**************************** ...
- Vue 编程式导航,路由history模式
import Vue from 'vue' import App from './App.vue' import Home from './components/Home.vue' import Ne ...
- Vue躬行记(8)——Vue Router
虽然Vue.js未提供路由功能,但是官方推出了Vue Router(即vue-router库),以插件的形式支持.它与Vue.js深度集成,可快速的创建单页应用(Single Page Applica ...
- Vue Router的原理及history模式源码实现
Hash 模式 URL中 # 后面的内容作为路径地址,可以通过location.url直接切换路由地址,如果只改变了#后面的内容,浏览器不会向服务器请求这个地址,会把这个地址 记录到浏览器的访问历史中 ...
- 在nginx上部署vue项目(history模式);
在nginx上部署vue项目(history模式): vue-router 默认是hash模式,使用url的hash来模拟一个完整的url,当url改变的时候,页面不会重新加载.但是如果我们不想has ...
- vue项目的mode:history模式
最近做的Vue + Vue-Router + Webpack +minitUI项目碰到的问题,在此记录一下,Vue-router 中有hash模式和history模式,vue的路由默认是hash模式, ...
- 如何去除vue项目中的 # --- History模式
来自:https://www.cnblogs.com/zhuzhenwei918/p/6892066.html 侵删 使用vue-cli搭建的环境,在配置好路由之后,可以看到下面的情况: 但是不难发现 ...
随机推荐
- Django实现用户密码重置
使用Django内置的认证视图实现简单的通过邮箱重置密码的功能版本:django 1.11 在django.contrib.auth.views中提供了四个类视图用于密码重置 class Passwo ...
- 慢SQL汇总
select count(*) as aggregate from `yqz_feed_praise` where `uid` = '580242' and `praise_uid` <> ...
- UVa1595,Symmetry
这题居然是1A过的.....最近无比失落的心情顿时愉悦起来~ 将数据全部读入 先用二维数据来存储坐标(先把题做出来再说= =) 题目中的x,y的坐标范围是-1W到1W....在数组下标里是不能用负数保 ...
- Python连接SQLite数据库
SQLite作为一款轻型数据库,管理工具有很多,比如SQLite Expert Professional,很适合用来存储Python网站,爬虫的相关数据,下面列出基本的增删查改操作 读取操作: con ...
- LeetCode 26. Remove Duplicates from Sorted Array (从有序序列里移除重复项)
Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...
- git 初步
git command help file:///D:/Git/mingw64/share/doc/git-doc/git-config.html git 版本控制管理 之前并没有接触过git方面的知 ...
- .xlsx文件总是默认用2007 Microsoft Office component 打开,且无法更改用EXCEL打开的解决方法
之前装了OFFICE2003,后来改装了 OFFICE2007,之后XLSX文件双击总是用2007 Microsoft Office component 打开,导致无法打开. 解决方法: 打开注册表R ...
- Java基础——字符串构建器
StringBuilder类: 可以将许多小段的字符串构建一个字符串. StringBuilder builder = new StringBuilder(); //构造一个空的字符串构建器 buil ...
- iOS动画学习 -隐式动画
事务 Core Animation基于一个假设,说屏幕上的任何东西都可以(或者可能)做动画.你并不需要在Core Animation中手动打开动画,但是你需要明确地关闭它,否则它会一直存在. 当你改变 ...
- HDU1754 I hate it(线段树 单点修改)
好久没打线段树,来一道练练手,但说句实话,I really hate it!!!! 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管 ...