Constructors
Methods
addLang
- addLang(language, langData): this
Returns this
getLang
- getLang(): string
Returns string
getLangList
- getLangList(): {
desc: string;
key: string;
}[] Returns {
desc: string;
key: string;
}[]
getTranslations
- getTranslations(language?): null | Record<string, string>
Returns null | Record<string, string>
removeLang
- removeLang(language): this
Returns this
setLang
- setLang(language, callback?): this
Parameters
- language: string
Optional
callback: ((language: string) => void)- (language): void
Returns void
Returns this
t$
- t$(key, obj?, language?): string
Parameters
- key: string
Optional
obj: anyOptional
language: string
Returns string
i18n 国际化支持类 若需切换语言后更新页面内容,可以在切换语言的时候同步更新全局状态 lang,并将全局状态 lang 设置为
t$
的参数即可。具体可参考 web_base 或 vue-admin 案例
web_base vue-adminExample
Returns