Преглед изворни кода

feat(reactivity): add failSilently argument for onScopeDispose

Evan You пре 2 година
родитељ
комит
9a936aaec4
1 измењених фајлова са 2 додато и 2 уклоњено
  1. 2 2
      packages/reactivity/src/effectScope.ts

+ 2 - 2
packages/reactivity/src/effectScope.ts

@@ -136,10 +136,10 @@ export function getCurrentScope() {
  * @param fn - The callback function to attach to the scope's cleanup.
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
  */
-export function onScopeDispose(fn: () => void) {
+export function onScopeDispose(fn: () => void, failSilently = false) {
   if (activeEffectScope) {
     activeEffectScope.cleanups.push(fn)
-  } else if (__DEV__) {
+  } else if (__DEV__ && !failSilently) {
     warn(
       `onScopeDispose() is called when there is no active effect scope` +
         ` to be associated with.`,