最近发现一个兼容问题 vue-router 的this.$router 和 router-link方法在IE 下不管用,页面不能跳转(又是万恶的IE),最后百度找到了一个决绝兼容的方法记录一下!
<template>
<div id="app">
<router-view/>
</div>
</template>
<script>
export default {
name: 'qiaolu',
mounted () {
function checkIE () {
return '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style
}
if (checkIE()) {
window.addEventListener('hashchange', () => {
var currentPath = window.location.hash.slice(1)
if (this.$route.path !== currentPath) {
this.$router.push(currentPath)
}
}, false)
}
}
}
</script>