Subscribe on changes!

Script-Setup file can't be detected by 'include' property of keep-alive component

avatar
Jan 11th 2022

Version

3.2.25

Reproduction link

github.com

Steps to reproduce

I create four components that two by 'script-setup' and two by 'defineComponent' and 'script-setup'. Those two created by 'defineComponent' have 'name' property. Then I use 'keep-alive' component to cache dynamic components when I switch them(See App.vue). All of four components have the 'onUnmounted' hook and it will alert a message when the 'onUnmounted' hook activate. When I switch them by click four button, there will be alert while I switch between A and B, but will not while I do so between C and D. this means than the 'keep-alive' component doesn't cache A and B which only created by 'script-setup'.

What is expected?

the 'keep-alive' component doesn't cache A and B which only created by 'script-setup'.

What is actually happening?

the 'keep-alive' component doesn't cache A and B which only created by 'script-setup'.

avatar
Jan 12th 2022

see #4993

Would vue development team consider that use file name as default component name in future when setup-SFC component's name is missing instead of using extra script tag to declare the definite name to keep the coding fluency of setup-SFC component? After all 'setup-SFC' component may be frequently cached by 'keep-alive' component when it widely apply