js/ts文件中,导入i18n报错:Must be called at the top of a `setup` function
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
会在非组件情况下报错:
此时我们需要将上述导入方式改为:
import i18n from '@/lang/i18n';//@/lang/i18n为语言包位置
const { t } = i18n.global;
此时我们需要将上述导入方式改为: