参考:

  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 browsers

        history.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));
        }
        }
        };  

#在设计缓存时一定要考虑到上下文的依赖,过时的缓存有啥用呢

end

  

vue-router在ie9及以下history模式支持的更多相关文章

  1. 关于vue+element对ie9的兼容el-upload不支持在IE9上传

    关于vue+element对ie9的兼容el-upload不支持在IE9上传 https://lian-yue.github.io/vue-upload-component/#/zh-cn/ 解决方案 ...

  2. Vue history模式支持ie9

    vue 路由里面的history能让浏览器显示平常一样的链接,可以去掉#这种,但是在ie9下面会强制变成hash,因为history不支持ie9自动降级,可能就会影响美感,解决:可以在路由里面添加fa ...

  3. vue router mode 设置"hash"与"history"的区别

    router官网的说明如下: ********************************************我是官网说明分隔符--开始**************************** ...

  4. Vue 编程式导航,路由history模式

    import Vue from 'vue' import App from './App.vue' import Home from './components/Home.vue' import Ne ...

  5. Vue躬行记(8)——Vue Router

    虽然Vue.js未提供路由功能,但是官方推出了Vue Router(即vue-router库),以插件的形式支持.它与Vue.js深度集成,可快速的创建单页应用(Single Page Applica ...

  6. Vue Router的原理及history模式源码实现

    Hash 模式 URL中 # 后面的内容作为路径地址,可以通过location.url直接切换路由地址,如果只改变了#后面的内容,浏览器不会向服务器请求这个地址,会把这个地址 记录到浏览器的访问历史中 ...

  7. 在nginx上部署vue项目(history模式);

    在nginx上部署vue项目(history模式): vue-router 默认是hash模式,使用url的hash来模拟一个完整的url,当url改变的时候,页面不会重新加载.但是如果我们不想has ...

  8. vue项目的mode:history模式

    最近做的Vue + Vue-Router + Webpack +minitUI项目碰到的问题,在此记录一下,Vue-router 中有hash模式和history模式,vue的路由默认是hash模式, ...

  9. 如何去除vue项目中的 # --- History模式

    来自:https://www.cnblogs.com/zhuzhenwei918/p/6892066.html 侵删 使用vue-cli搭建的环境,在配置好路由之后,可以看到下面的情况: 但是不难发现 ...

随机推荐

  1. 关于python安装一些包时出现的错误解决方法

    1.关于wordcloud的安装 --win10,py3.6环境下安装总是出现安装错误,解决方法,下载wordcloud的wheel文件,进行安装. 详情参考:https://github.com/a ...

  2. Mongodb 认证鉴权那点事

    [TOC] 一.Mongodb 的权限管理 认识权限管理,说明主要概念及关系 与大多数数据库一样,Mongodb同样提供了一套权限管理机制. 为了体验Mongodb 的权限管理,我们找一台已经安装好的 ...

  3. Spring高级装配

    Spring高级装配 目录 一.Profile(根据开发环境创建对应的bean) 二.条件化的创建bean(根据条件创建bean) 三.处理自动装配歧义性(指定首选bean.限定符限制bean) 四. ...

  4. 【计算机网络】应用层(一) HTTP

      HTTP报文 HTTP报文是HTTP应用程序间发送的数据块,它由三部分组成:起始行(start line),首部(header)和主体(body),如下图所示:   从分类上,报文又可以分为请求报 ...

  5. visual studio no editoroptiondefinition export found for the given option nam

    今天用VS 2012打开项目,打开项目时,出现以下的bug.解决方法:清理了在C盘用户文件目录下的缓存. 具体的路径是:C:\Users\{当前用户}\AppData\Local\Microsoft\ ...

  6. C#设计模式之九装饰模式(Decorator)【结构型】

    一.引言 今天我们要讲[结构型]设计模式的第三个模式,该模式是[装饰模式].我第一次看到这个名称想到的是另外一个词语“装修”,我就说说我对“装修”的理解吧,大家一定要看清楚,是“装修”,不是“装饰”. ...

  7. LINUX 笔记-重定向 :<,<<,>,>>

    command>filename  把标准输出重定向到一个新文件中 command>>filename  把标准输出重定向到一个文件中(追加) command 1>filena ...

  8. LeetCode 566. Reshape the Matrix (重塑矩阵)

    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...

  9. MySQL(十六)之MySQL用户管理

    一.MySQL用户管理概述 MySQL是一个多用户的数据库,MYSQL的用户可以分为两大类: 超级管理员用户(root),拥有全部权限 普通用户,由root创建,普通用户只拥有root所分配的权限 二 ...

  10. 主键乱序插入对Innodb性能的影响

    主键乱序插入对Innodb性能的影响 在平时的mysql文档学习中我们经常会看到这么一句话: MySQL tries to leave space so that future inserts do ...