<template>
<div></div>
</template>
<script setup>
const emit = defineEmits(["update:modelValue"]);
const props = defineProps({
modelValue: {
type: Array,
defualt: [],
},
});
watch(
() => props.modelValue,
() => {
// 一些操作
},
{
immediate: true,
}
);
</script>
有没有办法,如果组件内部 emit 改变 modelValue 的值不触发组件内部 watch 监听,只有在父组件改变了传入的值才触发组件内部 watch 监听