vue-i18n 怎么用在data属性上切换到英文模式刷新变成了中文

 

 原代码:

 1 data() {
 2     return {
 3       resolutionSymbol: '×',
 4       btns: ['scale'],
 5       activeBtnIndex: 0,
 6       // orientations: [
 7       //   // { label: this.$t('orientation.adaptive'), value: 0 },
 8         { label: this.$t('orientation.vertical'), value: 1 },
 9         { label: this.$t('orientation.horizontal'), value: 2 }
10       // ],
11       orientation: 1
12     }
13   },

大概是data里不够动态(瞎猜):用computed

修改后:

1   computed: {
2     orientations() {
3       return [
4         // { label: this.$t('orientation.adaptive'), value: 0 },
5         { label: this.$t('orientation.vertical'), value: 1 },
6         { label: this.$t('orientation.horizontal'), value: 2 }
7       ]
8     }
9   },

 

posted @ 2022-02-25 16:32  CMirs  阅读(338)  评论(0)    收藏  举报