Strange behavior with watch and watchEffect #6176
-
vue-version: 3.2.25 Here is a snippet :
Normally, when i trigger a Thanks everyone ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I run it in the SFC, click the watch(() => refA.value, (newRefAValue) => {
console.log('WATCH on refA change displaying refC and refA');
console.log('refA value:', newRefAValue, 'refC value:', refC.value);
});
watchEffect(() => {
console.log('WATCH EFFECT changing refA value and triggered on refB change only normally');
console.log('refB value:', refB.value);
refA.value = Math.ceil(Math.random() * 10000);
}); are all not execut. watchEffect(() => {
debugger
// will trigger
console.log('refC',refC.value)
}) will execut. |
Beta Was this translation helpful? Give feedback.
I run it in the SFC, click the
trigger button
to trigger the
window.dispatchEvent(new CustomEvent('change_ref_c'))
,the codeare all not execut.
only my add new
watchEffect
will execut.