Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep-alive设置了 include 后,对应子组件使用是 <script setup> ,该子组件的 onActivated 生命周期失效 #5341

Closed
Oumae-Kumiko opened this issue Jan 29, 2022 · 1 comment

Comments

@Oumae-Kumiko
Copy link

Oumae-Kumiko commented Jan 29, 2022

Version

3.2.13

Reproduction link

sfc.vuejs.org/

Steps to reproduce

点击更改组件按钮。

What is expected?

  • 子组件只用了<script setup>语法糖,在父组件中能正确推导出子组件name
  • 父组件使用<script setup>语法糖,keep-aliveinclude能正确映射到对应的子组件。

What is actually happening?

  • 父组件使用 components 选项的键值无法正确缓存子组件,不会触发子组件的 onActivated
  • 父组件使用<script setup>语法糖无法像递归组件一样,推导出对应的子组件,不会触发子组件的 onActivated

keep-alive 文档内容:匹配首先检查组件自身的 name 选项,如果 name 选项不可用,则匹配它的局部注册名称 (父组件 components 选项的键值)。匿名组件不能被匹配。
虽然可以再用1个<script></script>标签声明name解决这个问题,但是按照上面的keep-alive文档内容,是否属于有其他方案?

@edison1105
Copy link
Member

duplicate of #4997

@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants