From 0fe0088e57018a4a31e3e168cc7cb0156b020fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?null=E4=BB=94?= <308241863@qq.com> Date: Thu, 8 Jul 2021 08:57:25 +0800 Subject: [PATCH] fix(watch): only trigger warning in the dev environment (#754) Co-authored-by: webfansplz <> --- src/apis/watch.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/apis/watch.ts b/src/apis/watch.ts index abddb89c..a03ba55d 100644 --- a/src/apis/watch.ts +++ b/src/apis/watch.ts @@ -298,11 +298,12 @@ function createWatcher( } else if (isFunction(s)) { return s() } else { - warn( - `Invalid watch source: ${JSON.stringify(s)}. + __DEV__ && + warn( + `Invalid watch source: ${JSON.stringify(s)}. A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`, - vm - ) + vm + ) return noopFn } }) @@ -310,11 +311,12 @@ function createWatcher( getter = source as () => any } else { getter = noopFn - warn( - `Invalid watch source: ${JSON.stringify(source)}. + __DEV__ && + warn( + `Invalid watch source: ${JSON.stringify(source)}. A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`, - vm - ) + vm + ) } const applyCb = (n: any, o: any) => {