react-native三种创建组建的方式

来源:互联网 发布:三维动画演示软件 编辑:程序博客网 时间:2024/05/17 18:03

方法一:ES6创建组件

export default class HolleCompany extends Component{    render() {        return (            <Text style={{fontSize:20,backgroundColor:'red'}}>Hello</Text>        );    }}

方法二:ES5创建组建

 var HolleCompany=React.createClass({     render() {        return <Text style={{fontSize:20,backgroundColor:'red'}}>Hello</Text>     } });module.exports=HolleCompany;

方法三:函数式,(无状态,不能使用this)

function HolleCompany() {    return <Text style={{fontSize:20,backgroundColor:'red'}}>Hello</Text>;}module.exports=HolleCompany;
阅读全文
0 0
原创粉丝点击