更新记录
1.1(2019-10-23) 下载此版本
添加了uni.showToast内容多语言显示
平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
- | - | - | - | √ | - | - | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
- | - | - | - | - | - | - | - | - | - | - |
很简单的一个demo,请自行忽略排版.
1.main.js引入vue-i18n(需要先下载vue-i18n.js)
2.main.js引入static/lang下的语言库js
3.可以参考下面的代码
import VueI18n from 'vue-i18n'
import LangEn from './static/lang/en'
import LangChs from './static/lang/zhCHS'
import LangCht from './static/lang/zhCHT'
Vue.use(VueI18n)
const i18n = new VueI18n({
locale: 'en',
messages: {
'en': LangEn,
'chs' : LangChs,
'cht' : LangCht
}
}) Vue.prototype._i18n = i18n
const app = new Vue({ i18n, ...App })
4.index页面
1)
computed: {
i18n () {
return this.$t('message')
}
},
2)
change:function(){ this._i18n.locale = 'chs' },
3)
<view>
<text >{{ i18n.hello}}</text>
> </view>