how to watch the class data change #8118
Replies: 1 comment
-
<script setup lang=ts>
import { reactive,watch } from 'vue'
class Test{
a:number;
b:Map=new Map();
}
const msg = reactive(new Test())
const click = ()=>{
msg.a = 123;
console.log("++++",msg)
msg.b.set("a","1234")
msg.b.set("c","1234")
}
watch(()=>msg.b,(newV,oldV)=>{console.log("---",newV)},{deep:true})
</script>
{{ msg.a }}{{ msg.b }}test |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
like the codes, the watch never ouput anything at browser, anyone have some ideas?
Beta Was this translation helpful? Give feedback.
All reactions