“vue3 typescript” globalProperties变量在移动网页时初始化为null。

huangapple go评论76阅读模式
英文:

"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;

huangapple
  • 本文由 发表于 2023年6月19日 18:50:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76505908.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定