zoukankan      html  css  js  c++  java
  • Vue路由-ie上地址栏输入路由页面不更新

    情景:在ie11地址栏上直接输入路由,开发环境页面能正常刷新,在测试环境上不更新也不报错。测试环境在火狐、chrome浏览器地址栏上直接输入路由能正常更新页面。但是在App.vue中添加以下代码后,测试环境在ie11也能正常更新页面。
    闲话不多说,上代码:
    const IE11RouterFix = {
    methods: {
    hashChangeHandler: function() { this.$router.push(window.location.hash.substring(1, window.location.hash.length)) },
    isIE11: function() { return !!window.MSInputMethodContext && !!document.documentMode }
    },
    mounted: function() { if (this.isIE11()) { window.addEventListener('hashchange', this.hashChangeHandler) } },
    destroyed: function() { if (this.isIE11()) { window.removeEventListener('hashchange', this.hashChangeHandler) } }
    }

    new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App),
    mixins: [IE11RouterFix]
    })
  • 相关阅读:
    查看 lib 库信息
    评委打分(C++ 容器综合练习)
    二阶段12.16
    对搜狗输入法的使用心得
    二阶段12.14
    二阶段12.13
    二阶段12.12
    典型用户描述
    水王(课堂练习)
    一阶段11.21
  • 原文地址:https://www.cnblogs.com/hanzeng1993/p/12106175.html
Copyright © 2011-2022 走看看