Js bug记录:cbsy:411 Uncaught TypeError: Cannot read properties of undefined (reading ‘split‘)

报错:cbsy:411 Uncaught TypeError: Cannot read properties of undefined (reading 'split')
    at formatter (cbsy:411)
    at Object. (echarts.min.js:6)
    at Array.map ()
    at Object.f [as map] (echarts.min.js:1)
    at Object.s. [as getFormattedLabels] (echarts.min.js:6)
    at a.n [as getFormattedLabels] (echarts.min.js:6)
    at echarts.min.js:6
    at r.getLabelInterval (echarts.min.js:6)
    at e (echarts.min.js:6)
    at a.render (echarts.min.js:6)

原因:

一开始看的还以为是函数调用错误还是不支持啥的,后来一想不可能,然后对数据进行了观察,val可能会存在空值的情况,也就是相当于java的空指针异常,在调用split()函数之前要对参数进行非空判断

源代码

Js bug记录:cbsy:411 Uncaught TypeError: Cannot read properties of undefined (reading ‘split‘)_第1张图片

 解决方法:对调用方法的元素进行非空判断

Js bug记录:cbsy:411 Uncaught TypeError: Cannot read properties of undefined (reading ‘split‘)_第2张图片

 

你可能感兴趣的:(Bug记录,开发记录,开发语言,js)