Javascript 这是一个分解分配的示例吗?

Javascript 这是一个分解分配的示例吗?,javascript,reactjs,object,Javascript,Reactjs,Object,在查看React时,我想知道为什么handlechange方法没有按如下方式编码。正如我所尝试的,这两种方法似乎都有效。想知道这是否是一个解构赋值 handleCelsiusChange(temperature) { this.setState({scale: 'c', temperature: temperature}); } 原始代码: constructor(props) { super(props); this.handleCelsiusChange

在查看React时,我想知道为什么handlechange方法没有按如下方式编码。正如我所尝试的,这两种方法似乎都有效。想知道这是否是一个解构赋值

 handleCelsiusChange(temperature) {
    this.setState({scale: 'c', temperature: temperature});
  }

原始代码:

 constructor(props) {
    super(props);
    this.handleCelsiusChange = this.handleCelsiusChange.bind(this);
    this.handleFahrenheitChange = this.handleFahrenheitChange.bind(this);
    this.state = {temperature: '', scale: 'c'};
  }

  handleCelsiusChange(temperature) {
    this.setState({scale: 'c', temperature});
  }

  handleFahrenheitChange(temperature) {
    this.setState({scale: 'f', temperature});
  }

代码取自

 handleCelsiusChange(temperature) {
    this.setState({scale: 'c', temperature: temperature});
  }


第二种是使用ECMAScript 2015中提供的较短符号。您可能会看到带有示例的描述

不,它不是。。。只是将对象作为参数传递给函数。您是指将
temperature:temperature
更改为Just
temperature
?这不是拆建,而是
  handleCelsiusChange(temperature) {
    this.setState({scale: 'c', temperature});
  }