echarts报错提示echarts is not defined &&& echarts柱状图分段叠加展示

在浏览器页面实现如下图效果所示,放在项目里后报错,排查后发现渐变透明色代码中的color: new echarts 设置完报错,方法一,在使用渐变色的地方改为new this.$echarts可以加载出来,为什么呢?方法二,在当前项目引入import echarts from “echarts” ,报错消失引入import时位置不能放在export default的内部,而在顶层作用域,否则报错import is a reserved wordapp.title = '堆叠柱状图'
摘要由CSDN通过智能技术生成

在浏览器页面实现如下图效果所示,放在项目里后报错,排查后发现渐变透明色代码中的color: new echarts 设置完报错,

  • 方法一,在使用渐变色的地方改为new this.$echarts可以加载出来,为什么呢?

  • 方法二,在当前项目引入
    import echarts from “echarts” ,报错消失
    引入import时位置不能放在export default的内部,而在顶层作用域,否则报错import is a reserved word
    在这里插入图片描述

app.title = '堆叠柱状图';

option = {
   
    backgroundColor: '#fff',
    tooltip: {
   
        trigger: 'axis',
        axisPointer: {
    // 坐标轴指示器,坐标轴触发有效
            type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
        }
    },
    legend: {
   
        data: ['组合有功尖电能', '组合有功峰电能', '组合有功平电能', '组合有功谷电能'],
        textStyle: {
   
            color: '33363b'
        }
    },
    grid: {
   
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: [{
   
        type: 'category',
        data: 
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值