// 爺組件
import { defineComponent, reactive, toRefs, onMounted, provide ,computed} from 'vue';
const state = reactive({
tableData: [],
});
// 因爲數據是異步的所以需要使用computed
provide('myList',computed(() => state.tableData))
const getList = async () => {
const res = await getList();
state.tableData = res.list || []
}
onMounted(() => {
getList ();
});
// 孫組件
import { defineComponent,inject } from 'vue';
const mylist = inject('myList')