问题描述
- JS split报错问题,使用了Echart
-
{ title: '天数', field: 'ChiD', width: 120, formatter: function (value, row, index) { var CD1 = ""; CD1 = value; var CMingX = []; CMingX = CD1.split(","); value = ""; for(var c=0;c<CMingX.length-1;c++) { value += CMingX[c] + "n"; } return value; } value =" 总计:8 天,2015-07-01,2015-07-02,2015-07-03,2015-07-06,2015-07-07,2015-07-08,2015-07-09,2015-07-10," 目的 = 总计:8 天 2015-07-01 2015-07-02 2015-07-03 2015-07-06 2015-07-07 2015-07-08 2015-07-09 2015-07-10 现在报错:Uncaught TypeError: Cannot read property 'split' of undefined
解决方案
说明传入的value为undefined或者null,调用split报错了
CD1 = value;改成下面这样就不会报错了
CD1 = value||'';
解决方案二:
你把那个value toString看看呢 感觉类型问题吧
解决方案三:
同意楼上的【说明传入的value为undefined或者null,调用split报错了】,检查下你传进来的value值
时间: 2024-09-16 05:30:23