有关于setState的问题

clipboard.png

像第一张图片上的这个是什么意思 不都应该是下方的写法么 麻烦大佬帮我讲解下!

clipboard.png

阅读 2.3k
3 个回答

简单的理解:

 this.setState({
    from,
    till,
});

等价于

 this.setState({
    from:from,
    till:till,
});

这是ES6允许的写法

let startDate = "";
this.setState({
    startDate
});

相当于

let startDate = "";
this.setState({
    startDate:startDate
});
推荐问题