正在做百度前端技术学院的一道JS题目,遇到了困难,完整代码如下:
零基础JavaScript编码(三)
- 北京空气质量:90
- 上海空气质量:70
- 天津空气质量:80
- 广州空气质量:50
- 深圳空气质量:40
- 福州空气质量:32
- 成都空气质量:90
通过控制台看到报错 Cannot read property 'length' of undefined,render里面的data.length无法获取是undefined。这里的data是getData()返回的数组啊,为什么获取不到?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
排序方法返回的是数组么?你仔细看看return是不是写错地方了!!!
sortAqiDatadoes not return things, soaqiDatais "undefined", so when you callrender(apiData)you ends with "Cannot read property 'length' of undefined" becauseapiDataisundefinedfunction sortAqiData(data) {
getData()和sortAqiData()的返回值你都没有调用。。
. length() 呢?
获取元素的数组是伪数据