vite_ts_auto/src/i18n/index.ts

17 lines
492 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { createI18n } from "vue-i18n";
// ? 从本地存储中获取数据
const languageData = localStorage.getItem("i18nStore");
// 配置多语言
const i18n = createI18n({
// 如果要支持 compositionAPI此项必须设置为 false
legacy: false,
// ? 全局注册$t方法
globalInjection: true,
// 本地内容存在时,首次加载如果本地存储没有多语言需要再刷新
messages: languageData ? JSON.parse(languageData).i18n : {}
});
export default i18n;