Skip to content

keepAlive组件中的instance在打包后添加__v_cache=内部cache map,或者管理内部cache map方法 #5178

Closed
@paul-xia

Description

@paul-xia

What problem does this feature solve?

在实现管理系统或者通常会有缓存组件内容时候,可用使用vue-router,keepAlive组件非常好的解决。

但在管理缓存内容时候,keepAlive只提供了max cache count和include, exclude(component name)功能。

在多个链接对应一个组件,如: /xx/edit, /xx/create, /xx/edit?a=1时候,对应内部组件都只有唯一文件name,这时候使用include,exclude就不能区别管理缓存内容,所以需要手动管理cache。

在开发环境中已有instance.__v_cache, 但是编译后,instance上无__v_cache。

源码KeepAlive.ts中,有判断过滤掉了。

if (DEV || FEATURE_PROD_DEVTOOLS) {
;(instance as any).__v_cache = cache
}

十分希望去掉过滤,在prod环境中添加支持,感谢阅读。

What does the proposed API look like?

keepAlive component, instance.__v_cache or instance.{delete(key){}, refresh(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