美文网首页
vue-router在ie11无法跳转

vue-router在ie11无法跳转

作者: 1024k纯金 | 来源:发表于2019-05-20 22:36 被阅读0次

网上找到的解决方案如下所示

new Vue({

  el: '#app',

  router,

  store,

  render: function (createElement) {

    if ('-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style) {

      window.addEventListener('hashchange', () => {

        var currentPath = window.location.hash.slice(1)

        if (this.$route.path !== currentPath) {

          this.$router.push(currentPath)

        }

      }, false)

    }

    return createElement(App);

  }

})

-ms-scroll-limit 和 -ms-ime-align 这两个应该是ie特有的样式吧,判断出ie然后手动驾驶hashChange事件监听路由变化

相关文章

网友评论

      本文标题:vue-router在ie11无法跳转

      本文链接:https://www.haomeiwen.com/subject/ujfrzqtx.html