V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
edis0n0
V2EX  ›  程序员

Angular SPA 分包加载后如果不同包没有同时更新,跳转路由经常会导致浏览器缓存的旧版本的包被加载,必须要手动刷新一下,怎么解决?

  •  
  •   edis0n0 · Nov 5, 2022 · 1028 views
    This topic created in 1280 days ago, the information mentioned may be changed or developed.
    const routes: Routes = [
      {
        path: 'main',
        loadChildren: () => import('./main/main.module').then(x => x.MainModule),
        canActivate: [AuthGuard]
      },
      {path: 'sub', loadChildren: () => import('./sub/sub.module').then(x => x.SubModule)},
    ];
    

    例如这样的 route ,从 main/123this.router.navigate 跳转 sub/456 时,如果没有同时更新两个包的话浏览器总是会加载缓存的旧版本SubModule,必须要刷新。

    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3763 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:46 · PVG 12:46 · LAX 21:46 · JFK 00:46
    ♥ Do have faith in what you're doing.