鸿蒙中创建一个数组,长度不固定的number 的数组
·
this.num = Array.from<undefined, number>(
{ length: this.gameData.gridRows },
(_, index) => index)
if(this.num[1]= 2){
}
this.num2 = Array.from<undefined, number>(
{ length: this.gameData.gridColumns },
(_, index) => index)
if(this.num[1]= 2){
}
其中 this.gameData.gridRows 是会这个数组的长度。
**不能这样写 //this.num = Array.from({iterable:this.gameData.gridRows},(_, index) => index)**
更多推荐



所有评论(0)