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实例化的时刻,以下所示:
<StockList theme="white" showFluctuation stockList={list} isEmptyList={false} />
constructor中的参数args含有这些属性,也就是
args[0] = {
theme: "white",
showFluctuation,
stockList,
isEmptyList
}