mpvue中出现Cannot read property 'getAttribute' of undefined

  • 1
新手上路,请多包涵
<template>
<div class="echarts-wrap">
    <mpvue-echarts :echarts="echarts" :onInit="onInit" canvasId="demo-canvas">

    </mpvue-echarts>
</div>
</template>
<script>

import echarts from "../../../node_modules/echarts/dist/diy-echarts.js"
import mpvueEcharts from '../../../node_modules/mpvue-echarts'

let chart=null
function initChart(canvas,width,height){
    chart=echarts.init(canvas.null,{
        width:width,
        height:height
    });
    canvas.setChart(chart);

    var xDataArr=['张三','李四','王五','闰土','小明','茅台','二姐','大强']
    var yDataArr=[88,34,66,87,34,100,56,78]
    var option={
        xAxis:{
            //类别的轴
            type:'category',
            //数据来源
            data:xDataArr
        },
        yAxis:{
            //数量轴
            type:'value'
            //data在series下查找
        },
        series:[{
            name:'语文',
            type:'bar',
            data:yDataArr
        }]

    };//Echarts配置项

    chart.setOption(option);
    return chart;//返回chart后可以自动绑定触摸操作
}
export default{
    components:{
        mpvueEcharts
    },
    data(){
        return{
            echarts,
            onInit:initChart
        }
    }
}


回复
阅读 169
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏