Cannot read property 'getAttribute' of null
2018-01-10 15:58
519 查看
//data: para,
//重新传递参数
data: { city: citycode, startTime: STime, endTime: ETime, Status: Status },//para,
报错位置定位在
myChart = ec.init(document.getElementById(container));//'main'改成container
myChart 是个全局变量
改成局部变量
//加个局部变量
var myChartbind;
http://blog.csdn.net/you23hai45/article/details/51595108
1、错误描述
谷歌浏览器
火狐浏览器
[html] view
plain copy
TypeError: Cannot read property 'getAttribute' of null
at Object.s.init (echarts-all.js:1)
at buildChart (map.js:720)
at b.$scope.queryChart (map.js:138)
at map.js:175
at angular.min.js:146
at e (angular.min.js:43)
at angular.min.js:45
2、错误原因
用echarts编写饼图时,利用随机数生成数据源,并用定时器定时刷新图形
[html] view
plain copy
window.setInterval(randomData(),1000);
但是在重新获取饼图容器时出现这个错误
由于echarts图形ID是由后台传输过来的,并且是根据图形数据一起传过来,出现了图形容器还未生成,但是数据已经来了,这样就会出现这个问题:找不到图形容器
3、解决办法
(1)如果图形数据和图形ID一起传输过来,先保证图形容器已存在,后生成图形;可以利用定时器延后图形数据
(2)可以将图形数据和图形ID分为两个请求接口,分别同步进行,先保证图形容器存在,然后再生成图形
//重新传递参数
data: { city: citycode, startTime: STime, endTime: ETime, Status: Status },//para,
报错位置定位在
myChart = ec.init(document.getElementById(container));//'main'改成container
myChart 是个全局变量
改成局部变量
//加个局部变量
var myChartbind;
http://blog.csdn.net/you23hai45/article/details/51595108
1、错误描述
谷歌浏览器
火狐浏览器
[html] view
plain copy
TypeError: Cannot read property 'getAttribute' of null
at Object.s.init (echarts-all.js:1)
at buildChart (map.js:720)
at b.$scope.queryChart (map.js:138)
at map.js:175
at angular.min.js:146
at e (angular.min.js:43)
at angular.min.js:45
2、错误原因
用echarts编写饼图时,利用随机数生成数据源,并用定时器定时刷新图形
[html] view
plain copy
window.setInterval(randomData(),1000);
但是在重新获取饼图容器时出现这个错误
由于echarts图形ID是由后台传输过来的,并且是根据图形数据一起传过来,出现了图形容器还未生成,但是数据已经来了,这样就会出现这个问题:找不到图形容器
3、解决办法
(1)如果图形数据和图形ID一起传输过来,先保证图形容器已存在,后生成图形;可以利用定时器延后图形数据
(2)可以将图形数据和图形ID分为两个请求接口,分别同步进行,先保证图形容器存在,然后再生成图形
相关文章推荐
- 安卓Webview 加载网页 Uncaught TypeError: Cannot read property 'getItem' of null",
- Uncaught TypeError: Cannot read property 'getItem' of null
- Cannot read property 'getElementsByTagName' of null解决办法
- echarts-all.js:1 Uncaught TypeError: Cannot read property 'getAttribute' of null
- html创建canvas画布失败"cannot read property 'getContext' of null"
- 调用百度报Cannot read property 'lng' of null错误
- Uncaught TypeError: Cannot read property 'value' of null
- 关于JS出现的Cannot read property 'XXX' of null错误
- 关于React “Cannot read property 'setState' of null” 的错误
- Pansoft 启动成功但是登录时提示 Cannot read property 'charCodeAt' of null
- “Cannot read property 'classList' of null” when using classList.add
- canvas 在chrome预览时 Cannot read property 'getContext' of null
- Echarts Cannot read property 'modLayer' of null
- 在开发Ext 项目中如果遇到 Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null
- js事件处理程序 Uncaught TypeError: Cannot read property 'addEventListener' of null
- Uncaught TypeError: Cannot read property 'click' of null问题的解决
- Uncaught TypeError: Cannot read property 'prototype' of null using Openerp 7.0
- Cannot read property 'push' of null
- Uncaught TypeError: Cannot read property 'offsetTop' of null
- Uncaught TypeError: Cannot read property 'value' of null