在app.vue里面
globalData: {
$t: ''
},
onLaunch(){
this.globalData.$t = val => {
return this.$t(val);
};
},
在nvue页面使用
<view>{{ $t('conn.phone') }}</view>
let app = getApp().globalData;
methods:{
$t(text) {
return app.$t(text);
},
}