es6类

作者: Vijay_ | 来源:发表于2018-04-17 22:17 被阅读10次
  • 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);
    }

}

相关文章

网友评论

      本文标题:es6类

      本文链接:https://www.haomeiwen.com/subject/ggqmkftx.html