Is there any property on components to determine whether they're nested inside KeepAlive? #8162
-
In Vue 2.x I could determine if they are nested in KeepAlive when
One solution that probably would work would be to iterate over the parent components until I find KeepAlive, But I'm hoping for a nicer solution. |
Beta Was this translation helpful? Give feedback.
Answered by
chenxch
Apr 26, 2023
Replies: 2 comments 5 replies
-
You can use the |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
samueleiche
-
maybe this can help const isKeptAlive = (instance) => {
return instance.vnode.shapeFlag & 256 // 256 is ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the
onActivated
statement cycle to judge.demo