如何把下面forEach循环改成for循环:
v.cityData.forEach(function(e) {
let name = e.name.substr(0, 1);
let len = e.cities.length;
v.anchorMap[name] = y;
y -= titleHeight + len * itemHeight;
});
如何把下面forEach循环改成for循环:
v.cityData.forEach(function(e) {
let name = e.name.substr(0, 1);
let len = e.cities.length;
v.anchorMap[name] = y;
y -= titleHeight + len * itemHeight;
});
for (let i = 0, iLen = v.cityData.length; i < iLen; i++) {
let e = v.cityData[i];
let name = e.name.substr(0, 1);
let len = e.cities.length;
v.anchorMap[name] = y;
y -= titleHeight + len * itemHeight;
}
for(let e of v.cityData) {
let name = e.name.substr(0, 1);
let len = e.cities.length;
v.anchorMap[name] = y;
y -= titleHeight + len * itemHeight;
}
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
3 回答1.4k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
回答完这个问题之后有种难以言表的心情。。。