打字稿 - 在数组中使用for循环用于Obj

时间:2018-04-21 02:28:38

标签: angular typescript

假设我有一个像这样的数组:

let bodyDataAnswer = {
  'answers':[{
    'question_id':this.verifyCustomer.questions[0].id,
    'int_result':this.verifyCustomer.questions[0].answer_template.answers["0"].int_result,
    'string_result': this.verifyCustomer.questions[0].answer_template.answers["0"].string_result
    },
    {
      'question_id':this.verifyCustomer.questions[1].id,
      'int_result':this.verifyCustomer.questions[1].answer_template.answers["0"].int_result,
      'string_result': this.verifyCustomer.questions[1].answer_template.answers["0"].string_result,
    },
    {
      'question_id':this.verifyCustomer.questions[2].id,
      'int_result': this.verifyCustomer.questions[2].answer_template.answers["0"].int_result,
      'string_result':this.verifyCustomer.questions[2].answer_template.answers["0"].string_result
    }
    ]
  }

有什么方法可以使用for循环吗?因为下次这会更大

1 个答案:

答案 0 :(得分:1)

vlan_number