Skip to content

keepalive能否支持根据key来配置如何处理缓存 #9747

@xq5273508

Description

@xq5273508

What problem does this feature solve?

我有一个类似于qq聊天的窗体,聊天框需要缓存用户行为(滚动条位置、输入框内容等),keepalive渲染的组件都是同一个,只是加了不同的key,用keepalive可以实现我的需求的,当我关闭某个用户的聊天窗口时,配置include时缓存是没法清除;
我的组件结构如下:

<keep-alive :include="included">
    <chat v-if="_interlocutor.Key===interlocutor" :interlocutor="_interlocutor"
                      :key="_interlocutor.Key" v-for="_interlocutor in interlocutors"/>
</keep-alive>

现在只能通过_vnode.componentInstance获取到keys,和cache,在程序中自己来处理。处理起来比较麻烦。

What does the proposed API look like?

看代码发现include和exclude的配置都是判断的组件name,能否增加include和exclude对key的支持。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions