Bootstrap

vue3 调用router-view下的组件方法

1、使用router-view插槽

<template>
	<router-view v-slot="{ Component }">
		<component ref="routerViewRef" :is="Component" />
	</router-view>
</template>

2、在setup中定义ref

setup() {
	const routerViewRef = ref();
	return {
		routerViewRef,
	}
}

3、使用:可以使用routerViewRef来调用对应方法

routerViewRef.value?.load();
;