zoukankan      html  css  js  c++  java
  • React创建组件的三种方式比较和入门实例

    推荐文章: https://www.cnblogs.com/wonyun/p/5930333.html

      创建组件的方式主要有:

      1、function 方式

      2、class App extends React.component {}

      3.  React.creatClass 

    大致区别: function创建组件的方式最为高效,但是其只能传递props,而不能使用状态等。 extends React.component 的方式功能更为强大,他不仅可以通案过 this.props 来使用prop并且还可以使用状态管理,另外,还可以通过 extends 继承 React.pureComponent ,这样,我们就更加容易使用钩子函数等。

    {array}变量展开数组全部成员

    React.Children.map(this.props.children, function (child) {
    return <li>{child}</li>;
    })
    无子节点 undefined 1:对象 2:数组

    getDefaultProps getInitialState this.props表示那些一旦定义,就不再改变的特性,而 this.state是会随着用户互动而产生变化的特性。{{}}组件样式为对象,1为标识2为对象

    React 入门实例教程

    阮一峰:http://www.ruanyifeng.com/blog/2015/03/react.html

  • 相关阅读:
    141. Linked List Cycle
    140. Word Break II
    139. Word Break
    138. Copy List with Random Pointer
    137. Single Number II
    136. Single Number
    135. Candy
    134.Gas Station
    linux/ubuntu 设置代理服务器
    sqlserver/mssql 查看版本信息
  • 原文地址:https://www.cnblogs.com/cosyer/p/7246632.html
Copyright © 2011-2022 走看看