解决方案:vue路由在ie下无反应
在应用中加入下面这块话即可。
if (!!window.ActiveXObject || 'ActiveXObject' in window) {
window.addEventListener('hashchange', function(){
// window.location.reload()
console.log('走没?')
console.log(_this.$route)
// console.log(_routerCase)
let currentPath = window.location.hash.slice(1)
if (_this.$route.path !== currentPath) {
_this.$router.push(currentPath)
}
})
}
完整代码如下:
new Vue({
el: '#app',router,
components: { App },
template: '<App/>',
mounted() {
var _this = this;
if (!!window.ActiveXObject || 'ActiveXObject' in window) {
window.addEventListener('hashchange', function(){
// window.location.reload()
console.log('走没?')
console.log(_this.$route)
// console.log(_routerCase)
let currentPath = window.location.hash.slice(1)
if (_this.$route.path !== currentPath) {
_this.$router.push(currentPath)
}
})
}
}
})
-
« 上一篇:
获取url中参数的方法getUrlParams(url)
-
webstorm 模板内置变量
:下一篇 »