중첩 배열을 반환하는 typescript에서 함수를 선언하고 있지만 반환 유형을 선언하고 반환되는 배열을 선언하는 방법을 잘 모르겠습니다. 누구든지 도울 수 있습니까? 여기에 내가 가진 것
myFunction(items: any): [] {
const data = [];
for (const item of items) {
data.push([item.parameter1, item.parameter2])
}
return data; // IDE throws error here
}
다음을 사용할 수 있습니다 myFunction(): any[][]
.
예 :
myFunction(): any[][] {
let data = [,];
data = [[1], [2], [3]];
console.log(data);
return data;
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다