- 监听基本使用 监听props/data
<script>
export default {
props: {
sonPlay: {},
},
watch: {
sonPlay(newV,oldV) {
console.log(newV,oldV)
}
},
}
</script>
- deep 深度监听,可监听到对象、数组的变化
<script>
export default {
props: {
sonPlay: {},
},
watch: {
sonPlay:{ //深度监听,可监听到对象、数组的变化
//使用handler
handler (newV, oldV) {
console.log(newV,oldV)
},
deep:true
},
}
</script>
网友评论