0

我了解 ES6 解构和传播运算符,但我对它们的一起使用感到困惑。有人可以将其分解为外行可以理解的方式吗?

const index = ({title, description, ...props}) => {
  return (
    <div>
      
    </div>
  )
}

这是如何运作的?

4

1 回答 1

1

像这样的东西。WhereeverythingElseExceptTitleAndDescription创建一个新对象,该对象具有参数的所有可枚举自己的属性,除了titledescription

const index = (arg) => {
  let title = arg.title;
  let description = arg.description;
  let props = everythingElseExceptTitleAndDescription(arg);
  return (
    <div>
      
    </div>
  )
}
于 2020-10-22T13:26:58.223 回答