微前端 qiankun bug 记录

180 阅读1分钟

qinankun 使用bug logs

Failed to exectute 'replace' on 'Location'

134856885-801f106b-202e-4500-a198-d444b21d7d04.png

  • 因为vue-router@4.xvue-router@3.x 版本不兼容导致
  • 需要在vue-router@3.x 文件的afterEach 钩子中对state 处理下
    
    const router = new Router({
      mode: 'history',
      base: '/iot',
      routes: [...routes, ...UseNorm]
    })
    
    export default router
    
    router.afterEach((to, from, next) => {
      const state = {
        ...history.state,
        current: '/iot' + to.fullPath
      }
      history.replaceState(state, '', window.location.href)
    })