爲什麼arr.entries()for循環在TS中不起作用? 這部作品在鉻控制檯爲什麼arr.entries()for循環在TS中不起作用?
var arr = ['a', 'b', 'c'];
var e = arr.entries();
for (let [index, elem] of e) {
debugger;
console.log(`index = ${index}, elem = ${elem}`);
}
得很好,但在打字稿2.1.4 也不知沒有斷點,爲什麼我得到這個錯誤在TS: Error:(67, 35) TS2495:Type 'IterableIterator<[number, string]>' is not an array type or a string type.
我可以設置爲:any
但obviosuly這不是想法
問候
肖恩
我編譯你的準確的代碼與定位'es6',它很好。你是否編譯了你發佈的相同代碼或其他東西? –