【问题标题】:Ionic 3 how to use for loop in typescript?Ionic 3如何在打字稿中使用for循环?
【发布时间】:2018-08-08 14:47:18
【问题描述】:

我们可以在HTML中使用ngFor,就像

*ngFor="let file of files"

但我想在打字稿中应用 For 循环。如何使用 For 循环

【问题讨论】:

标签: typescript for-loop ionic-framework


【解决方案1】:

很简单:

for(let file of this.filename) {
   console.log(file);
}

或喜欢:

for(let i = 0; i < this.filename.length; i++) {
   console.log(this.filename[i]);
}

【讨论】:

    【解决方案2】:

    参考此代码,

    for (let file of this.files){
    
    }
    

    【讨论】:

      【解决方案3】:

      这里是你如何使用forEach:

      files.forEach((res) => {
         //your each object will be in res
         //example: let value = res
      });
      

      【讨论】:

        猜你喜欢
        • 2022-11-02
        • 2018-10-21
        • 2020-01-06
        • 2021-03-22
        • 1970-01-01
        • 1970-01-01
        • 2019-09-24
        • 2018-02-04
        • 1970-01-01
        相关资源
        最近更新 更多