是谁传给了constructor参数

class StockList extends Component {
  constructor(...args) {
    super(...args);

    this.state = {
      stockList: [],
      showStockList: false,
      showFluctuation :args[0].showFluctuation || false, //是否显示涨跌额那一列
      sortedHeader:args[0].sortedHeader && true, //是否显示涨跌额那一列
    };
  }
}

以上代码是es6建立组件的方式,该段代码建立了StockList组件,在StockList实例化的时候,以下所示:es6

<StockList theme="white" showFluctuation stockList={list} isEmptyList={false} />

constructor中的参数args含有这些属性,也就是this

args[0] = {
    theme: "white",
    showFluctuation,
    stockList,
    isEmptyList
   }
相关文章
相关标签/搜索