【发布时间】:2020-05-15 17:24:18
【问题描述】:
我是 reactjs 新手。我真的不明白 props 和 state 是如何工作的。根据我的研究,我发现道具是从父母传给孩子的。并且状态只能在单个组件中使用。但是当我看到下面的这些代码时,我不知道它是如何工作的。有人可以为我提供一个很好的例子和解释。谢谢
let 和 var 的区别不仅如此
default class WildList extends React.Component {
constructor(props){
super(props);
this.props = props;
let {keyword, dealstatus} = this.props;
this.state = {
keyword
}
}
}
PS = 这个 WildList 类也在不同的组件中使用。
【问题讨论】:
-
“不只是 let 和 var 之间的区别”是一个不同的问题,它有很好的答案 - stackoverflow.com/questions/762011/…
标签: reactjs state var react-props let