Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我遇到了一个小问题,我正在创建一个 vuejs 包,我在其中使用 vue-i18n 来翻译东西。
问题是,如果用户没有安装 vue-i18n,它会破坏包(显然因为我使用它)。
你知道防止这种情况的方法吗?
我的第一种方法是仅 v-if 模板中的翻译来检查 i18n 是否在窗口中注册,但如果用户以不同的方式命名对象,这显然不起作用。
你可以检查 this.$i18n 是否存在