import { createApp } from 'vue';
import App from './App.vue';
const app = createApp(App);
// 全局注册 自定义指令(directive)
setupDirective(app);
// 全局注册 状态管理(store)
setupStore(app);
//这里进行全局属性 or 方法挂载
app.config.globalProperties.count='123456789'
app.use(router).use(i18n).mount('#app');
获取全局挂载的属性/方法
import { getCurrentInstance } from "vue";
let internalInstance = getCurrentInstance();
onMounted(() => {
console.log(30000);
});
onMounted(() => {
console.log("getCurrentInstance", internalInstance);
console.log(
"getCurrentInstance",
internalInstance?.appContext.config.globalProperties.count
);
});