i18n前端国际化 vue 在Echart中不生效

  • 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);
    },
      },
};
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值