鍍金池/ 問答/HTML/ router-link在IE11下不跳轉(zhuǎn)

router-link在IE11下不跳轉(zhuǎn)

router-link路由跳轉(zhuǎn),在chrome和Edge都能正常跳轉(zhuǎn)下一個(gè)頁面,IE下點(diǎn)擊沒有任何反應(yīng)。
圖片描述

回答
編輯回答
款爺

這個(gè)是vue-router的一個(gè)issue

這里面討論的內(nèi)容跟你說的一樣,在IE11上無法用router-link跳轉(zhuǎn),主要是當(dāng)url的hash change的時(shí)候?yàn)g覽器沒有做出相應(yīng)。里面主要是做了一個(gè)兼容。

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)
}

這個(gè)兼容就是當(dāng)檢測(cè)到瀏覽器為IE的時(shí)候,手動(dòng)給url加一個(gè)hashchange事件。

2018年9月13日 00:52
編輯回答
半心人

我也碰到同樣的問題,求大佬告知具體原因和解決方法

2018年2月7日 23:22