zoukankan      html  css  js  c++  java
  • react 三种组件定义方式

    import React from 'react';
    import ReactDOM from 'react-dom';
    /1、/function sayHello
    function SayHello(props){
    return <h1>hello {props.name}</h1>
    }
    ReactDOM.render(
    <SayHello name="qq111111"/>,
    document.getElementById("root")
    )

    //2、React.createClass
    const SayHello2 = React.createClass({
    render(){
    return <h1>hello {this.props.name}</h1>
    }
    })
    ReactDOM.render(
    <SayHello2 name="qq11111221"/>,
    document.getElementById("root2")
    )
    //3、extends React.Component
    class SayHello3 extends React.Component{
    render(){
    return <h1>hello {this.props.name}</h1>
    }
    }
    ReactDOM.render(
    <SayHello3 name="qq11111221"/>,
    document.getElementById("root3")
    )

  • 相关阅读:
    奔溃瞬间1
    面试知识点blog汇总
    贪心
    树 和 图
    DFS 和 BFS
    STL
    哈希表
    手写堆
    并查集
    二项式反演学习笔记
  • 原文地址:https://www.cnblogs.com/zhangxintong1314/p/6565467.html
Copyright © 2011-2022 走看看