vue安装使用echarts报错“export ‘default‘ (imported as ‘echarts‘) was not found in ‘echarts‘

vue安装echarts
按官网方法安装npm install echarts --save
使用报错
"export ‘default’ (imported as ‘echarts’) was not found in ‘echarts’
研究后发现是官网直接安装的版本过高(5.0.0)
需要卸载后安装4.9.0
具体操作如下
1卸载

npm uninstall echarts 

2安装4.9.0版本

npm install echarts@4.9.0

运行成功
附引用实例

<template>
  <div>
   <div id="myChart" :style="{ width: '100%', height: '400px' }"></div>
  </div>
</template>

<script>

export default {
  data() {
    return {
     
    };
  },
  methods: {
    //柱状图
    drawLine() {
      let myChart = this.$echarts.init(document.getElementById("myChart"));
      this.$http
        .post("后台接口地址")
        .then(res => {
          if (res.data.msg == "success") {
            myChart.setOption({
              title: {},
              tooltip: {
                trigger: "axis",
                axisPointer: {
                  type: "shadow"
                }
              },
              grid: {
                left: "3%",
                right: "4%",
                bottom: "3%",
                containLabel: true
              },
              xAxis: {
                type: "category",
                data: '数据',
                axisLabel: {
                  textStyle: {
                    fontSize: 14
                  }
                }
              },
              yAxis: {
                max: 100,
                interval: 20
              },
              series: [
                {
                  name: "综合评分",
                  type: "bar",
                  barWidth: "80",
                  showBackground: true,
                  backgroundStyle: {
                    color: "rgba(110, 193, 244, 0.2)"
                  },
                  itemStyle: {
                    normal: {
                      color: "#29aed7"
                    }
                  },
                  data: '数据'
                }
              ]
            });
          }
        });
    },
  },

  mounted() {

    this.drawLine();

};
</script>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值