V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
hoveyLee00

Vue KeepAlive Tab 页问题

  •  
  •   hoveyLee00 · Nov 17, 2022 · 1720 views
    This topic created in 1257 days ago, the information mentioned may be changed or developed.

    Item 组件 Tab 详情页

    路由配置

    {
      path: "/item/:id,
      name: item
    }
    

    A 路由 /item/1
    B 路由 /item/2

    <KeepAlive :include="['Item']">  
      <component :is="view" :key="$route.fullPath"/>  
    </KeepAlive> 
    

    我可以根据 key 对 A 和 B 路由分别进行缓存,我关闭 B 详情页的时候可以使 A 详情页的缓存不被清理吗?

    2 replies    2023-02-07 15:41:26 +08:00
    WengX
        1
    WengX  
       Feb 2, 2023
    好像不行的吧,KeepAlive 缓存的是组件,而并非根据不同的 URL 进行缓存。估计你得自己做缓存了。
    hoveyLee00
        2
    hoveyLee00  
    OP
       Feb 7, 2023
    @WengX 哪里有没有简单例子,我看到有的框架实现了这种效果
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4019 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 10:25 · PVG 18:25 · LAX 03:25 · JFK 06:25
    ♥ Do have faith in what you're doing.