我的i18n引导文件
import { boot } from 'quasar/wrappers';
import { LocalStorage } from 'quasar';
import messages from 'src/i18n';
import { createI18n } from 'vue-i18n';
const storedLang = LocalStorage.getItem('anty-locale');
const i18n = createI18n({
locale: storedLang && storedLang === 'en' ? 'en-US' : 'ru-RU',
messages,
});
export default boot(({ app }) => {
app.use(i18n);
});
export { i18n };当我试图像这样导入vuex js文件时
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });我发生了一个错误SyntaxError:必须在setup函数的顶部调用
import i18n from 'boot/i18n';
i18n.t('common.user') //also doesn't work是否有正确的方法在..js/..ts文件中导入i18n?
发布于 2022-08-12 06:14:02
我就像这样修好了它起了作用。
import { i18n } from 'boot/i18n';
i18n.global.t('common.user'); // it workshttps://stackoverflow.com/questions/69687783
复制相似问题