我想做这样的事情:
const vegetableColors = {corn: 'yellow', peas: 'green'};
const {*} = vegetableColors;
console.log(corn);// yellow
console.log(peas);// green
我似乎无法找到或弄清楚该怎么做,但我真的以为我以前看过它!:P
注:我使用的是巴贝尔与stage设置为0;
语境:我试图在JSX中变得更干燥,而不是引用this.state或this.props无处不在。而且,如果数据发生更改,也不必继续添加属性以进行解构。
catspeake
肥皂起泡泡
桃花长相依
相关分类