我有功能
const myTranslation = async () => {
const translation = await i18n.loadNamespaces(['home']);
console.log(translation); //-> return undefinded
console.log(translation.t('title')); //-> return Uncaught (in promise) TypeError: Cannot read property 't' of undefined
};如何获取我的翻译home.title?
发布于 2020-07-12 15:07:07
i18n.loadNamespaces只加载所需的名称空间,为了进行转换,您需要使用i18n.t。
const myTranslation = async () => {
await i18n.loadNamespaces(['home']);
console.log(i18n.t('title'));
// --------------^
};https://stackoverflow.com/questions/62821146
复制相似问题