[英]ES6 deep nested object destructuring
I have an object called this.props
which contains 我有一个名为
this.props
的对象,其中包含
{
actions: Object,
dirty: false,
form: "Statement",
autofill: functon(),
**statement: Object**
}
statement
contains statement
包含
{
firstName: "John"
lastName: "Peter"
isConfirmed: true
}
I would like to extract statement
object and the isConfirmed
property in the same line using es6 destructuring 我想使用es6解构在同一行中提取
statement
对象和isConfirmed
属性
I've tried 我试过了
const { statement: isConfirmed, isAdmin } = this.props
which I get an error when I do let a = isConfirmed, b = statement
当我
let a = isConfirmed, b = statement
时,我得到一个错误
I would like to extract statement object and the isConfirmed property in the same line
我想在同一行中提取语句对象和isConfirmed属性
const { statement: { isConfirmed }, statement } = this.props;
That way you get both isConfirmed
and the whole statement
object. 这样你就得到了
isConfirmed
和整个statement
对象。
References: 参考文献:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.