Vue3.0中如何监听props、reactive里面的值的变化方法
export default defineComponent({
props: {
isOpen: Boolean,
},
emits: {
"close-modal": null,
},
setup(props, context) {
watch(
() => props.isOpen, // reactive同理
(newProps) => {
console.log(newProps);//查看新值
}
);
const closeModal = () => {
context.emit("close-modal");
};
return {
closeModal,
};
},
});
本文来自博客园,作者:RHCHIK,转载请注明原文链接:https://www.cnblogs.com/suihung/p/16889343.html