首页 > 其他 > 详细

elementui 使用echarts报错

时间:2021-06-05 18:37:50      阅读:50      评论:0      收藏:0      [点我收藏+]

echarts 使用时候报错:init方法

export default (imported as echarts) was not found in echarts
Cannot read property init of undefined

这种原因是你安装了5.0以上版本的echarts。

1.卸载5.0以上版本的echarts

npm uninstall echarts

2.安装指定版本的echarts

npm install echarts@4.8.0

这里安装5.0以下版本都行,之后就是正常操作了。。。。。。

3. main.js入口文件对组件进行全局配置

// 引入 echarts 插件
import echarts from echarts

// 配置成全局组件
Vue.prototype.$echarts = echarts
<template>
    <div id="chartColumn" style="width: 100%; height: 400px;">
    </div>

</template>
<script>
        import echarts from echarts
        export default {
            data(){
                return {
                    chartColumn: null
                }
            },
            mounted() {
                this.drawLine();
            },
            methods: {
                drawLine(){
                    this.chartColumn = echarts.init(document.getElementById(chartColumn));

                    this.chartColumn.setOption({
                      title: { text: Column Chart },
                      tooltip: {},
                      xAxis: {
                        type: category,
                        data: [Mon, Tue, Wed, Thu, Fri, Sat, Sun]
                      },
                      yAxis: {
                        type: value
                      },
                      series: [{
                        data: [820, 932, 901, 934, 1290, 1330, 1320],
                        type: line
                      }]
                });
                }
            }
        }
    </script>

技术分享图片

 

elementui 使用echarts报错

原文:https://www.cnblogs.com/ckfuture/p/14852222.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!