【问题标题】:Typescript & nuxt : i18n types doesn't workTypescript & nuxt:i18n 类型不起作用
【发布时间】:2021-11-02 06:46:52
【问题描述】:

我在 typescript 中使用 nuxtjs/i18n 并且我在 TS config 中添加了它的 types

{
  "compilerOptions": {
    "types": [
      "@nuxt/types",
      "@nuxtjs/i18n",
    ]
  }
}

但是在我想使用的组件中

this.$i18n.locales

我有这个错误

那么,如何修复 @nuxt/i18n 的类型错误?

【问题讨论】:

    标签: typescript vue.js nuxt.js vue-i18n nuxt-i18n


    【解决方案1】:

    试试这样的:

    import { LocaleObject } from '@nuxtjs/i18n'
    ...
    (this.$i18n.locales as LocaleObject[])
    

    【讨论】:

      猜你喜欢
      • 2020-04-10
      • 1970-01-01
      • 2020-07-23
      • 2021-08-23
      • 2020-02-17
      • 2022-10-07
      • 1970-01-01
      • 1970-01-01
      • 2020-05-26
      相关资源
      最近更新 更多