<script>
import { ref, watch } from 'vue';
export default {
name: '监听属性变化',
props: {
show: {
type: Boolean,
default: false
}
},
setup(props) {
let visible = ref(false);
watch(()=>props.show,(newValue,oldValue)=>{
console.log("newValue",newValue);
console.log("oldValue",oldValue);
if(newValue == true){
visible = true;
}
})
return{
visible,
}
},
}
</script>
网友评论