微信小程序使用ec-canvas实现echart折线图时报错处理方法


控制台报错: 不支持颜色:none

 

解决办法:参考 https://developers.weixin.qq.com/community/enterprisewechat/doc/0000c66e358490a3e89c7a7fc56400 下的回答

 

在 echarts 的 ec-canvas 目录下应该有一个 wx-canvas.js 文件,这个文件里应该提供了一个类,里面在初始化化会执行一个 _initStyle 方法,可以在这个方法中加入下面这段代码:

var styles = [

      "fillStyle",

      "strokeStyle",

      "globalAlpha",

      "textAlign",

      "textBaseAlign",

      "shadow",

      "lineWidth",

      "lineCap",

      "lineJoin",

      "lineDash",

      "miterLimit",

      "fontSize",

    ];

 

    styles.forEach((style) => {

      Object.defineProperty(ctx, style, {

        set: (value) => {

          if (

            (style !== "fillStyle" && style !== "strokeStyle") ||

            (value !== "none" && value !== null)

          ) {

            ctx["set" + style.charAt(0).toUpperCase() + style.slice(1)](value);

          }

        },

      });

    });

已解决

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM