- es6类中对应es5的实现
- alias = function|obj
对应es5中prototype的属性
constructor(props){
super(props);
this.state={
number:0
};
}
componentDidMount(){
setInterval(_=>this.setState(pre=>({number:pre.number+1})),1000);
}
对应es5对象的属性(在构造器内给this赋值)
style = {
fontSize:60,
color:"#3d85fd"
};
getNum=_=>{
console.log(123);
};
render() {
return (
<View>
<Text style={this.style}>{`${this.props.text},${this.state.number}`}</Text>
</View>
)
}
加static的对应es5中类函数对象的属性
static hello(){
console.log(123);
}
}