如果在父组件中无法直接修改子组件的值,可以考虑使用defineExpose方法暴露来修改子组件需要进行修改。
子组件抛出
import { ref,defineExpose } from "vue";
// 表单
const from = ref({
name:'',
floors:null,
area:null,
propertyFeePrice:null
})
// 暴露from
defineExpose({
from:from
})
父组件接收
// 接收子组件抛出的表单对象
const from = ref(null)
const editBuildingItem = (item) => {
dialogVisible.value = true
// from.value.from = item
console.log(from.value.from)
}
值
记录提醒自己哈哈哈!!!!!!!!!!