From ee460e275b4b261e10c506808897027a6c7ecb8c Mon Sep 17 00:00:00 2001 From: zhujianchen <11088169@vivo.xyz> Date: Wed, 10 Apr 2019 21:11:08 +0800 Subject: [PATCH] fix: when prop is object or array, deep=true, watcher's cb always run --- src/core.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index e043a5a..13d26ae 100644 --- a/src/core.js +++ b/src/core.js @@ -312,8 +312,10 @@ export default { if (~['[object Object]', '[object Array]'].indexOf(getType(this.$props[prop]))) { opts.deep = true } - this.$watch(prop, () => { - this.changeHandler() + this.$watch(prop, (val, oldVal) => { + if (val !== oldVal) { + this.changeHandler() + } }, opts) } })