如何把下面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.7k 阅读
2 回答3.2k 阅读✓ 已解决
3 回答1.7k 阅读✓ 已解决
5 回答798 阅读
4 回答2.2k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
3 回答837 阅读✓ 已解决
回答完这个问题之后有种难以言表的心情。。。