typescript - Typescript & nuxt:i18n 类型不起作用
问题描述
我在 typescript 中使用nuxtjs / i18n并且我在TS config中添加了它的类型:
{
"compilerOptions": {
"types": [
"@nuxt/types",
"@nuxtjs/i18n",
]
}
}
但是在我想使用的组件中
this.$i18n.locales
我有这个错误
那么,如何修复 @nuxt/i18n 的类型错误?
解决方案
尝试这样的事情:
import { LocaleObject } from '@nuxtjs/i18n'
...
(this.$i18n.locales as LocaleObject[])
推荐阅读
- django - django-channels 更新慢 - redis
- symfony - 将捆绑配置注入没有全局变量的树枝
- android - android设置每个buildTypes的productFlavors的signingConfigs
- python - 在 Python 中迭代时间序列(numpy)
- java - 计算器 AWT - 对 2 个数字求和 - GUI 界面 - 服务器/客户端
- postgresql - 使用时区调整时间戳
- java - 使用 servlet 在浏览器上未显示图像
- node.js - 在一个应用程序中运行多个 LoopBack 实例?
- powershell - 在 Powershell 中拉取子字符串
- javascript - 未捕获的类型错误:无法读取未定义的属性“国家”