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