nuxt vue element 前端 使用国际化 i18n
在nuxt
官网中就有如何使用国际化得
nuxt 国际化
1、插值表达式
{{ $t('footer.about') }}
2、label
:label=" $t('Home.Machineselection') "
3、message
表单校验
message: this.$t("modify-pwd.enternewPwd"),
4、placeholder
:placeholder="$t('modify-pwd.enternewPwd')"
5、$message
this.$message({
message: `${ret.data.msg}`,
})
6、表单校验
var validateCode = (rule, value, callback) => {
if (value === "") {
callback(new Error(this.$t("modify-pwd.enter-Code")));
} else if (value !== this.form.code) {
callback(new Error(this.$t("modify-pwd.IncorrectCode")));
} else {
callback();
}
};
7、v-for data
infoIn: [
{ title: "exchange.ContractOutstanding"},
{ title: "exchange.SupportedCurrencies",},
{ title: "exchange.HandlingFee", },
{title: "exchange.Transactionsupport", }
]
注意:是数组包含对象
使用
{{$t(item.title)}}
8、国际化 占位
"LSRate":"{symbol} Longs VS Shorts" //en.json
//使用
{{$t("LSRate",{symbol:symbol})}}