i18n无法动态改变

475 阅读1分钟

data是一次性生产的,你这么写只能是在 data 初始化的时候拿到这些被国际化的值,并不能响应变化。官方的解决办法是,建议我们将表达式写到computed属性里,不要写到data里。

可以写在data中,作为原数据,当新数据过来可以更新数据且不影响i18n的更新

computed: {
			
			statusArrN() {
				return this.statusArr
			}
		},

data() {
			return {
				statusArr: [{
					status: this.$t('message.待取件'),
					count: 0,
					color: '#169DE3',
					tabIndex: 1,
					isClick: false
				}]}