router-link在IE11下不跳转

router-link路由跳转,在chrome和Edge都能正常跳转下一个页面,IE下点击没有任何反应。
图片描述

阅读 11.7k
2 个回答

这个是vue-router的一个issue

这里面讨论的内容跟你说的一样,在IE11上无法用router-link跳转,主要是当url的hash change的时候浏览器没有做出相应。里面主要是做了一个兼容。

if (
  '-ms-scroll-limit' in document.documentElement.style && 
  '-ms-ime-align' in document.documentElement.style
) { // detect it's IE11
  window.addEventListener("hashchange", function(event) {
    var currentPath = window.location.hash.slice(1);
    if (store.state.route.path !== currentPath) {
      router.push(currentPath)
    }
  }, false)
}

这个兼容就是当检测到浏览器为IE的时候,手动给url加一个hashchange事件。

我也碰到同样的问题,求大佬告知具体原因和解决方法

1 篇内容引用
推荐问题