【发布时间】:2023-01-12 06:53:12
【问题描述】:
是否可以使用解构以更少的代码行来声明这个声明?
const identification_type = this.phaseOneForm.controls.identification_type.value;
const identification_number =this.phaseOneForm.controls.identification_number.value;
const date_of_issue = this.phaseOneForm.controls.date_of_issue.value;
const date_of_birth = this.phaseOneForm.controls.date_of_birth.value;
const pep = this.phaseOneForm.controls.pep.value;
const us = this.phaseOneForm.controls.us.value;
const qualified_investor = this.phaseOneForm.controls.qualified_investor.value;
我试过了:
const {
value: identification_type,
value: identification_number,
value: date_of_issue,
value: date_of_birth,
value: pep,
value: us,
value: qualified_investor,
} = this.phaseOneForm.controls;
但不起作用
【问题讨论】:
-
你做的一切都是对的,但需要使用这个语法
identification_type: {value: identification_type},
标签: javascript arrays object javascript-objects