这里是es6的新手。有没有办法用es6特性来缩短这段代码?我试图从一个对象中解构,并将这些提取的属性放入一个新的对象中。
const { Height, Width, Location, MapAttachmentTypes,
ZoomLevelAdjustment, CustomPushPins, CenterPushpinStyle, ScaleFactor } = args;
const body = {
Height,
Width,
Location,
MapAttachmentTypes,
ZoomLevelAdjustment,
CustomPushPins,
CenterPushpinStyle,
ScaleFactor
};我试过了,但不起作用:
const body = { Height, Width, Location, MapAttachmentTypes, ZoomLevelAdjustment, CustomPushPins, CenterPushpinStyle, ScaleFactor } = args;发布于 2017-11-01 00:11:45
// new syntax
const body = {
...args
};
// es5
const body = Object.assign({}, args);https://stackoverflow.com/questions/47039793
复制相似问题