vuejs3 - 使用 quasar 框架在 vuex 模块中导入 vue-i18n
问题描述
我的 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: Must be called at the top of a setup
function
import i18n from 'boot/i18n';
i18n.t('common.user') //also doesn't work
有什么正确的方法可以在 .js/.ts 文件中导入 i18n 吗?
解决方案
推荐阅读
- python-3.x - 如何在烧瓶单元测试的发布请求中传递 html 表单?
- qt - 在 GridView 中的委托顶部绘制突出显示组件
- sqoop - Sqoop import failed "java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils"
- c++ - 您无权写入文件“ostream”所在的文件夹
- javascript - How can I prevent jQuery slideUp until form is filled?
- python - Packaging Python script for use by other users
- swift - 如何在 Swift 中解码结构的枚举
- flutter - Flutter:如何在子小部件的构建上下文之外的函数中访问“提供者”值?
- javascript - Script based Dependent Drop-Down List not working (Sheets)
- reactjs - pass variable from function to function in react js