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)**
Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐