vue 路由改变页面不刷新问题

时间:2021-08-23 20:26:57   收藏:0   阅读:29

 在 App.vue文件添加以下代码:

mounted() {
// 检测浏览器路由改变页面不刷新问题,hash模式的工作原理是hashchange事件
window.addEventListener(‘hashchange‘, () => {
  let currentPath = window.location.hash.slice(1)
    if (this.$route.path !== currentPath) {
    his.$router.push(currentPath)
  }
}, false)
},

原文:https://www.cnblogs.com/wj365794/p/15177222.html

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!