我正在寻找将一个大学项目翻译成其他语言,所以我查找了一些方法,并找到了 I18n。我使用
npm install vue-i18n@10.
将其安装在项目的根目录中
我在文件顶部进行导入,调用
createI18n
函数,当我使用 app.use(i18n)
时,它会给出以下错误:
The argument of type ‘I18n<{}, {}, {}, string, true>’ is not assignable to the parameter of type ‘Plugin<[]>’.
The type ‘I18n<{}, {}, {}, string, true>’ cannot be assigned to the type ‘{ install: (app: App<any>) => any; }’.
Property types ‘install’ are incompatible.
The type ‘(app: App<any>, ...options: unknown[]) => void’ cannot be assigned to the type ‘(app: App<any>) => any’.
The parameter types ‘app’ and ‘app’ are incompatible.
The ‘onUnmount’ property is missing in the type ‘import(’c:/Projetos/pibic/Tutor_de_ensino_TS/aplicacao/frontend/node_modules/@vue/runtime-core/dist/runtime-core.) App<any>‘, but it is mandatory in the type “import(”c:/Projetos/pibic/Tutor_de_ensino_TS/aplicacao/node_modules/@vue/runtime-core/dist/runtime-core’).App<any>'.ts(2345)
runtime-core.d.ts(1041, 5): ‘onUnmount’ is declared here.
const i18n: I18n<{}, {}, {}, string, true>
我已经尝试从头开始创建一个Vue项目,看看它是否是当前项目的配置,但当我使用app.use(i18n)时出现了同样的错误
我正在使用这些版本的 vue:
aplicacao@ C:\Projetos\pibic\Tutor_de_ensino_TS\aplicacao
└─┬ [email protected]
└─┬ [email protected]
└─┬ @vue/[email protected]
└── [email protected] deduped
看起来你写的是I18n而不是i18n?这将使用类型而不是模块。