有关watch触发的一个问题 #11749
Answered
by
Alfred-Skyblue
lih21
asked this question in
Help/Questions
有关watch触发的一个问题
#11749
-
Beta Was this translation helpful? Give feedback.
Answered by
Alfred-Skyblue
Aug 30, 2024
Replies: 1 comment 3 replies
-
请提供复现案例,以便于排查原因 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
template 是函数环境 render,每次修改 input 的时候,会触发 render,然后每次执行render都会生成新的 {a:1,b:2} 此时创建的 obj 和上一次执行render 时不一样,所以触发了 watch,但是这种场景似乎只会在 vue2中出现,我在 playground 中并未发现这一问题。
您可以暂时将obj声明在 setup 中,避免每次render生成新的obj: