i18n.code-snippets 配置
{
"vue-i18n-mall": {
"scope": "vue-html",
"prefix": "vt",
"body": "\\$t('passenger.$1')", //passenger-国际化文档名
"description": "vue i18n mall"
},
"vue-i18n-mall-close": {
"scope": "vue-html",
"prefix": "vtc",
"body": "{{\\$t('passenger.$1')}}",
"description": "vue i18n mall"
},
"vue-i18n-mall-js": {
"scope": "javascript, typescript",
"prefix": "vt",
"body": "this.\\$t('passenger.$1')",
"description": "vue i18n mall"
},
"vue-i18n-mall-external": {
"scope": "javascript, typescript",
"prefix": "vte",
"body": "i18n.t('passenger.$1')",
"description": "vue i18n mall"
}
}
快捷键:vt+回车 / vtc+回车
//标签:vtc + 回车
<span>{{$t('passenger.rest_tip')}}</span>
//函数里面采用:vt + 回车
this.$t('passenger.rest_tip')
如果带不定的参数形况下的国际化
<span>{{$t('passenger.rest_tip',[depListName])}}</span>
this.$t('passenger.rest_tip',[depListName])
//翻译中的样子
rest_tip: '是否重置{0}下PC8得设备的店员数据',
//多个的情况
<span>{{$t('passenger.rest_tip',[depListName, depId, dep])}}</span>
rest_tip: '是否重置{0}下PC8得{1}设备的{2}店员数据',
在js中引入
import i18n from "@/plugins/i18n" // 自己写的i18n配置
i18n.t('alwaysTrue')