美文网首页
Vue中Element ui使用echarts 报错 Canno

Vue中Element ui使用echarts 报错 Canno

作者: 菜的只能打代码 | 来源:发表于2021-01-06 14:58 被阅读0次

    报错提示:

    1.试了在main.js里写:

    import echarts from 'echarts'

    Vue.prototype.$echarts = echarts

    然后组件内引用

    this.$echarts.init(document.getElementById('idname'));

    无用-------------

    2. 又试了只在组件内引用

    import echarts from 'echarts'

    echarts.init(document.getElementById('idname'));

    无用-------------

    3. 在init之前检查了document.getElementById('idname') 并不是null,是确实存在的对象

    4. 最后main.js也不用了,import 也不用了,直接require

    let echarts = require('echarts');

    let myChart = echarts.init(document.getElementById('myPancake'));

    官方文档按需引入 ECharts 图表和组件:

    https://echarts.apache.org/zh/tutorial.html#%E5%9C%A8%20webpack%20%E4%B8%AD%E4%BD%BF%E7%94%A8%20ECharts

    博客原文地址:https://blog.csdn.net/qq_35567179/article/details/110734722

    相关文章

      网友评论

          本文标题:Vue中Element ui使用echarts 报错 Canno

          本文链接:https://www.haomeiwen.com/subject/hjwnoktx.html