在函数内部隐藏这个吗?

时间:2017-03-19 18:24:52

标签: javascript reactjs

onClick被称为:

<th onClick={() => this.handleClick(13)}>Und.</th>

for(var key in this.state.tabs)执行后,突然thisundefined?我怀疑它是否与被置于不可变函数内的屏蔽有关? 有什么问题?

class StockTable extends React.Component {
    constructor(props) {
        super(props);
        this.state = {hidden: [], stockItems: [] tabs: {}}; 
    }
    handleClick(index) {
        var table = document.getElementById('stocktable');

        console.log(index);
        if(13 == index)
        {
            console.log("starting unhiding elements of length: " + this.state.hidden.length + " \n");
            this.state.hidden.forEach(function(elem){
                console.log("Unhiding column " + elem + "\n");
                for(var key in this.state.tabs) {

0 个答案:

没有答案