javascript-传播语法以删除
作者:互联网
我不会删除一把钥匙.看看这个
console.log(state);
我得到{1:{这里是下一个对象}},
下一个
const { 1: deletedValue, ...newState } = state;
console.log(newState);
console.log(state);
我得到
{1: {here is next object}}
{1: {here is next object}}
删除无效.我不理解为什么
邀请您在评论中描述数据的外观如何更准确:
state: {1: {id: 1, content: {name: "xyz", surname: "dsd"}},
2: {id: 2, content: {name: "abc", surname: "dsq"}}
}
解决方法:
看起来像是babeljs问题.
数字作为destructuring assignment的属性的问题.
var object = { 1: 40, foo: 41, bar: 42, baz: 43 },
{ 1: y, foo: z, ...x } = object;
//^
console.log(x);
console.log(y);
console.log(z);
以字符串数字作为目标属性,而不仅仅是数字.
var object = { 1: 40, foo: 41, bar: 42, baz: 43 },
{ '1': y, foo: z, ...x } = object;
//^^^
console.log(x);
console.log(y);
console.log(z);
标签:spread-syntax,ecmascript-6,babeljs,javascript 来源: https://codeday.me/bug/20191025/1925067.html