js 里的属性使用 computed 国际化, 不能放在 data 里

This commit is contained in:
Captain.B 2020-05-19 10:05:05 +08:00
parent 81922206ca
commit df14618621
1 changed files with 32 additions and 33 deletions

View File

@ -16,46 +16,45 @@
data() { data() {
return { return {
endDate: new Date(), endDate: new Date(),
unit: 'tests',
colorRange: ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127'], colorRange: ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127'],
locale: { }
// },
months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], computed: {
// Sun. Mon. Tues. Wed. Thur. Fri. Sat. locale() {
days: ['Sun', 'Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat'], return {
months: [
this.$t('commons.months_1'),
this.$t('commons.months_2'),
this.$t('commons.months_3'),
this.$t('commons.months_4'),
this.$t('commons.months_5'),
this.$t('commons.months_6'),
this.$t('commons.months_7'),
this.$t('commons.months_8'),
this.$t('commons.months_9'),
this.$t('commons.months_10'),
this.$t('commons.months_11'),
this.$t('commons.months_12')
],
days: [
this.$t('commons.weeks_0'),
this.$t('commons.weeks_1'),
this.$t('commons.weeks_2'),
this.$t('commons.weeks_3'),
this.$t('commons.weeks_4'),
this.$t('commons.weeks_5'),
this.$t('commons.weeks_6')
],
No: 'No', No: 'No',
on: ',', on: ',',
less: 'Less', less: 'Less',
more: 'More' more: 'More'
}, }
},
unit() {
return this.$t('commons.test_unit')
} }
}, },
mounted() {
this.locale.months = [
this.$t('commons.months_1'),
this.$t('commons.months_2'),
this.$t('commons.months_3'),
this.$t('commons.months_4'),
this.$t('commons.months_5'),
this.$t('commons.months_6'),
this.$t('commons.months_7'),
this.$t('commons.months_8'),
this.$t('commons.months_9'),
this.$t('commons.months_10'),
this.$t('commons.months_11'),
this.$t('commons.months_12')
];
this.locale.days = [
this.$t('commons.weeks_0'),
this.$t('commons.weeks_1'),
this.$t('commons.weeks_2'),
this.$t('commons.weeks_3'),
this.$t('commons.weeks_4'),
this.$t('commons.weeks_5'),
this.$t('commons.weeks_6')
];
this.unit = this.$t('commons.test_unit')
}
} }
</script> </script>