- 1
因为data()是一次性生产的,并不能响应变化。定义的数据如果需要跟随国际化转换需要定义在computed中。
//data:[中文,英文]
computed: {
data() {
return [
this.$t('common.chinese'),
this.$t('common.English'),
]
}
},
methods: {
getFileDetail () {
this.$notify.warning({
title: '提示',
message: this.getListMsg,
duration: 3 * 1000
})
}
-2 经过实践这个方法当然是可行的,但是大佬同事使用了另一种写法.
`${ this.$t('common.English')}`
-3vue-i18n & echarts遇到的问题和解决方法,watch()监听。
watch: {
"$i18n.locale"(newValue) {
this.init();
},
},
mounted() {
this.init();
},
computed(){
legend: {
//顶部快捷操作条
textStyle: {
//字体
fontSize: 12, //字体大小
color: "#ffffff", //字体颜色
},
right: 20,
// data: ["部门", "集团"],
data: [
// `${this.$t("common.department")}`,
// `${this.$t("common.group")}`,
this.$t("common.department"),
this.$t("common.group"),
],
},
},
methods: {
init() {
// y轴
// this.option.series[0].data = [120, 200, 150];
// x轴
// this.option.xAxis.data = ["2022-02", "2022-03", "2022-04", "2022-05"];
this.myChart = echarts.init(
document.getElementById("riskLineChartRight")
);
// 绘制图表
this.myChart.setOption(this.option);
},
},
};