1.引入路由,定义数据
<template>
<Screen :parent-data="parentData" @action="handleAction" />
</template>
const parentData = ref({
isButtonShow: true,
});
2.数据接收
import { ref, defineProps, defineEmits, onMounted, computed } from 'vue';
const props = defineProps({
parentData: { type: Object },
});
const showButtons = computed(() => props.parentData?.isButtonShow ?? false);
3.双向传递
const emit = defineEmits(['action']);
emit('action', btn.id); //子传父