英文:
"vue3 typescript" globalProperties variable is initialized to null When move a webpage
问题
我期望 this.$isDebug 是 true。但 this.$isDebug 是未定义的。
英文:
main.ts
const app = createApp(App)
.use(router)
.use(createPinia())
.use(vuetify)
.use(vue3GoogleLogin, googleLogin)
const global = app.config.globalProperties;
global.isDebug = true;
vue-shim
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$isDebug: true;
}
}
i expect this.$isDebug is true. but this.$isDebug is undefined
答案1
得分: 0
尝试这样做:
const globalProperties = app.config.globalProperties;
globalProperties.$isDebug = true;
英文:
It seems like there is an inconsistency between how you define the global property and how you access it.
Try this:
const globalProperties = app.config.globalProperties;
globalProperties.$isDebug = true;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论