父传子
template
// 父组件
<SetWarning
ref="setWarning"
:con-list="conList"
@getEarlywarnUpdateFun="getEarlywarnUpdateFun"
/>
<script setup name="father">
import { reactive, ref, getCurrentInstance } from 'vue'
//v3父调子
const { proxy } = getCurrentInstance()
const setWarning = ref()
const conList = ref([])
const fun =()=>{
proxy.$refs.setWarning.conList = conList
}
</script>
//子组件
<script setup name="SetWarning">
import { reactive, ref, defineExpose,defineEmits } from 'vue'
const conList = ref([])
defineExpose({
conList
})
//v3子传父
const emit = defineEmits(['getEarlywarnUpdateFun'])
const getEarlywarnListFun = () => {
{
emit('getEarlywarnUpdateFun')
}
}