Open ythy opened 1 year ago
appContext
const vNode = h(XXX) vNode.appContext = context
setup
import { getCurrentInstance } from 'vue'
onMount()
import { ref, onMounted, getCurrentInstance } from 'vue' export default function useContext() { const context = ref() onMounted(() => (context.value = getCurrentInstance()?.appContext)) }
应当手动传入
appContext
如何在
setup
控件中获取appContext
import { getCurrentInstance } from 'vue'
onMount()
中获取实例保存在ref中使用, 在onMount()
外取不到