在写echarts图表时遇见这样的问题,报错信息提示:Uncaught (in promise) TypeError:Cannot read property ‘textStyle’ of null
出现此问题的原因及解决方法
- 由于折线图横坐标的数据是动态获取的,所以当数据还没有获取到时,相当于横坐标上是没有数据的,那么此时对横坐标做出的字体样式就会出现这样的信息提示:Uncaught
(in promise) TypeError:Cannot read property ‘textStyle’ of null - 对数据做容错处理就好了,例如请求回来的数据是数组添加上 ( || [] )