Skip to content

Commit 5322f84

Browse files
committed
1. 修改vue-i18n为本地引入形式
2. 处理样式兼容性问题
1 parent 6dffef0 commit 5322f84

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed

common/vue-i18n.min.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/page-nav/page-nav.vue

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44
<image class="logo" src="https://cdn.uviewui.com/uview/common/logo.png" mode="widthFix"></image>
55
<view class="nav-info">
66
<view class="nav-title__text">
7-
<!-- {{$t('common.title')}} -->
8-
{{title}}
7+
{{$t('common.title')}}
98
</view>
109
<view class="nav-slogan">
11-
<!-- {{$t('common.intro')}} -->
12-
{{desc}}
10+
{{$t('common.intro')}}
1311
</view>
1412
</view>
1513
</view>
1614
<view class="nav-desc">
1715
{{desc}}
1816
</view>
19-
<!-- <view class="lang" @tap="switchLang">
17+
<view class="lang" @tap="switchLang">
2018
<u-icon size="46" color="warning" :name="lang"></u-icon>
21-
</view> -->
19+
</view>
2220
</view>
2321
</template>
2422

@@ -29,20 +27,20 @@
2927
title: String,
3028
},
3129
computed: {
32-
// lang() {
33-
// return this.$i18n.locale == 'zh' ? 'zh' : 'en';
34-
// }
30+
lang() {
31+
return this.$i18n.locale == 'zh' ? 'zh' : 'en';
32+
}
3533
},
3634
methods: {
37-
// switchLang() {
38-
// this.$i18n.locale = this.$i18n.locale == 'en' ? 'zh' : 'en';
39-
// this.vuex_tabbar[0].text = this.$t('nav.components')
40-
// this.vuex_tabbar[1].text = this.$t('nav.js')
41-
// this.vuex_tabbar[2].text = this.$t('nav.template')
42-
// uni.setNavigationBarTitle({
43-
// title: this.$t(this.title)
44-
// });
45-
// }
35+
switchLang() {
36+
this.$i18n.locale = this.$i18n.locale == 'en' ? 'zh' : 'en';
37+
this.vuex_tabbar[0].text = this.$t('nav.components')
38+
this.vuex_tabbar[1].text = this.$t('nav.js')
39+
this.vuex_tabbar[2].text = this.$t('nav.template')
40+
uni.setNavigationBarTitle({
41+
title: this.$t(this.title)
42+
});
43+
}
4644
}
4745
}
4846
</script>

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import Chinese from '@/common/locales/zh.js';
2929
import English from '@/common/locales/en.js';
3030

3131
// VueI18n
32-
import VueI18n from 'vue-i18n'
32+
import VueI18n from '@/common/vue-i18n.min.js'
3333

3434
// VueI18n
3535
Vue.use(VueI18n)

pages/example/components.nvue renamed to pages/example/components.vue

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
data() {
2121
return {
2222
list: list,
23-
desc: '众多组件覆盖开发过程的各个需求,组件功能丰富,多端兼容。让你快速集成,开箱即用。',
23+
//desc: '众多组件覆盖开发过程的各个需求,组件功能丰富,多端兼容。让你快速集成,开箱即用。',
2424
}
2525
},
2626
computed: {
@@ -29,17 +29,17 @@
2929
return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
3030
}
3131
},
32-
// desc() {
33-
// return this.$t('components.desc');
34-
// }
32+
desc() {
33+
return this.$t('components.desc');
34+
}
3535
},
3636
onShow() {
37-
// uni.setNavigationBarTitle({
38-
// title: this.$t('nav.components')
39-
// });
37+
uni.setNavigationBarTitle({
38+
title: this.$t('nav.components')
39+
});
4040
},
4141
created() {
42-
//console.log(this.abc);
42+
4343
},
4444
methods: {
4545
openPage(path) {
@@ -48,12 +48,10 @@
4848
})
4949
},
5050
getGroupTitle(item) {
51-
// return this.$i18n.locale == 'zh' ? item.groupName : item.groupName_en
52-
return item.groupName;
51+
return this.$i18n.locale == 'zh' ? item.groupName : item.groupName_en
5352
},
5453
getFieldTitle(item) {
55-
// return this.$i18n.locale == 'zh' ? item.title : item.title_en
56-
return item.title;
54+
return this.$i18n.locale == 'zh' ? item.title : item.title_en
5755
}
5856
}
5957
}

uview-ui/components/u-avatar-cropper/u-avatar-cropper.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export default {
229229
};
230230
</script>
231231

232-
<style scoped>
232+
<style scoped lang="scss">
233233
@import '../../libs/css/style.components.scss';
234234
235235
.content {

0 commit comments

Comments
 (0)