import {createApp} from 'vue'
import App from './App.vue';
const app = createApp(App);
app.config.globalProperties.foo = 'bar'
app.config.globalProperties.test = 'bar'
app.mount('#app')
import {ComponentInternalInstance, getCurrentInstance} from 'vue'
export default function useCurrentInstance() {const { appContext} = getCurrentInstance() as ComponentInternalInstance
const ctx = appContext.config.globalProperties;
return {ctx}
}
import useCurrentInstance from "../useCurrentInstance";// 依据本人创立的门路引入
setup: () => {const { ctx} = useCurrentInstance();
const getFoo = () => {console.log(ctx) //{foo: "bar" test: "bar"}
}
return {getFoo}
}