在main.js中添加mounted函数,在函数中判断浏览器是否为IE
mounted () {
// 判断浏览器是否为IE
const isIE = (
/MSIE (\d+\.\d+);/.test(navigator.userAgent) || ~navigator.userAgent.indexOf('Trident/')
)
// 兼容ie iframe切换路由不生效
if (isIE) {
window.addEventListener(
'hashchange',
() => {
var currentPath = window.location.hash.slice(1)
if (this.$route.path !== currentPath) {
this.$router.push(currentPath)
}
},
false
)
}
}