在 ES6 中,是否可以创建局部变量并直接引用它们,而不是 this.像this.name.
例如,在下面的代码中,我该怎么做才能让写作{name}而不是一直写下去{this.name}。(this.在变量前面加有点麻烦!)
class User extend React.Component {
name = "Joe";
render() {
// is it possible to write {name} instead of {this.name}
return <div>{name}</div>
}
}