You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1, 打开浏览器控制台 (Open the browser console)
2, 点击按钮后立即再次点击 (Click the button and immediately click again)
3, 可以看到控制台上打印的数字, 因为 watch 依旧存在 (You can see the numbers printed on the console, Because the 'watch' still exists)
What is expected?
我以为 KeepAlive 缓存中组件在卸载前, 'effect' 能被自动处理 (I thought the 'effect' of components in KeepAlive cache could be automatically processed before uninstallation)
What is actually happening?
缓存组件的 effect 没有被自动处理 (The 'effect' of caching components has not been automatically processed)
This issue was discovered when I was learning about effectoScope. I learned online that single file component setup automatically clears effects within its scope, but third-party component libraries require the use of effectoScope. Later, I learned about onScopeDispose. When I was writing lifecycle related hooks, I found that the components in KeepAlive cache did not have callback for uninstallation cycles, and after testing with timer+watch, I found that the effects of watch were not cleared. I don't know if this is wrong or intentional. I saw on the official website that onDeactivated is a replacement for onBeforeUnmount and onUnmount
The text was updated successfully, but these errors were encountered:
This is an introduction to the automatic clearing of effects within the setup scope chain. I understand it as any component's effects (watch, computed) within the setup scope chain can be automatically cleared
Vue version
3.4.32
Link to minimal reproduction
https://play.vuejs.org/#eNqFVd1u3EQUfpWDhWRHMbsJ4SpsAk0VpAKiCFIhJN947dnsNPaMZY93U0WRWig0oWwT0qKSJq2goiTQhkZCVKFJ6Musdzdv0TNjr+Nsk/bOPn/znXO++WZBOxcEpUZMtHGtEjkhDQRERMTBpMWoH/BQwAKEpAaLUAu5DzqG6rnrE0KC89wPMl+p3DfIihhmMZfUKCMXA0E5i4wFiwE46OeMMBGNgzJAXkf+LVpscUimOpghwHYEbRDpVDkwIdEYuo4hHkGswhZxlFlFGBO0p4mcnfeoM4cuYwgmJtOjaA2MNKXUsD2M7iMYOCb1Ym7eELN9ouAB8SLypjQdm1etQIYw97xV/MdWZaeVcjp5nDn+COIHni2I+gOo1MfwSx42akJn+XZycLXz70pvaylZ3+7c2kqWniUru2BcDAgDUSdQDXkzIi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浏览器控制台 (Open the browser console)
2, 点击按钮后立即再次点击 (Click the button and immediately click again)
3, 可以看到控制台上打印的数字, 因为 watch 依旧存在 (You can see the numbers printed on the console, Because the 'watch' still exists)
What is expected?
我以为 KeepAlive 缓存中组件在卸载前, 'effect' 能被自动处理 (I thought the 'effect' of components in KeepAlive cache could be automatically processed before uninstallation)
What is actually happening?
缓存组件的 effect 没有被自动处理 (The 'effect' of caching components has not been automatically processed)
System Info
Any additional comments?
这个问题是我在了解 effectScope 时发现的, 在网上了解到单文件组件setup作用域内是会自动清除 effect 的, 但是第三方组件库编写就需要使用 effectScope , 再之后了解到了onScopeDispose, 之后我在编写生命周期相关的hook时发现, KeepAlive 缓存中的组件没有卸载周期的回调, 而且用 定时器 + watch 测试完发现 watch 的 effec 没有被清理, 不知道这是错的还是有意为之, 我看见官网写了onDeactivated 是替代 onBeforeUnmount 与 onUnmounted 的.
This issue was discovered when I was learning about effectoScope. I learned online that single file component setup automatically clears effects within its scope, but third-party component libraries require the use of effectoScope. Later, I learned about onScopeDispose. When I was writing lifecycle related hooks, I found that the components in KeepAlive cache did not have callback for uninstallation cycles, and after testing with timer+watch, I found that the effects of watch were not cleared. I don't know if this is wrong or intentional. I saw on the official website that onDeactivated is a replacement for onBeforeUnmount and onUnmount
The text was updated successfully, but these errors were encountered: