0
点赞
收藏
分享

微信扫一扫

关于解决“export ‘default‘ (imported as ‘echarts‘) was not found in ‘echarts‘和Initialize failed: invalid

慎壹 2022-04-14 阅读 29
前端

将原来import echarts from 'echarts'换成import * as echarts from 'echarts'

// 基于准备好的dom,初始化echarts实例

 this.chart = echarts.init(document.getElementById('chart')),这个极为重要,按这个模板改数据

 // mounted(){

    //     this.setChart()

       

    // },中调用

         setChart() {

                 // 基于准备好的dom,初始化echarts实例

                this.chart = echarts.init(document.getElementById('chart'))

                var option;

                option = {

                xAxis: {

                    type: 'category',

                    data:  ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']

                },

                yAxis: {

                    type: 'value'

                },

                series: [

                    {

                    data: [150, 230, 224, 218, 135, 147, 260],

                    type: 'line'

                    }

                ]

                };

                 this.chart.setOption(option)

         }

    

举报

相关推荐

0 条评论