JavaScript/vue.js/getCurrentInstance
来自康健生活
< JavaScript | vue.js
标题文本
获取全局注册组件
<template>
<EchartsLinePanel
v-if="options"
:layerOptions="options"
@update:layerOptions="handleUpdateOptions"
/>
</template>
<script lang="ts" setup>
import { defineAsyncComponent, getCurrentInstance, type ComponentInternalInstance } from 'vue'
const { appContext } = <ComponentInternalInstance>getCurrentInstance()
const EchartsLinePanel = defineAsyncComponent({
loader: async () => {
// 获得 athena-echarts-line 组件
return appContext.components['athena-echarts-line']
},
})
</script>