美文网首页
React 组件 & Props

React 组件 & Props

作者: hanxianshe_9530 | 来源:发表于2019-10-18 16:05 被阅读0次

https://react.docschina.org/
React 是一个用于构建用户界面的 JavaScript 库。
React使用stateprops简化了数据的存储和处理方式。

1. React.Component

ShoppingList 是一个 React 组件类

class ShoppingList extends React.Component {
  render() {
    return (
      <div className="shopping-list">
        <h1>Shopping List for {this.props.name}</h1>
        <ul>
          <li>Instagram</li>
          <li>WhatsApp</li>
          <li>Oculus</li>
        </ul>
      </div>
    );
  }
}

// 用法示例: <ShoppingList name="Mark" />

组件接收一些参数,我们把这些参数叫做 props“props”“properties” 简写)。
当数据发生改变时,React 会高效地更新并重新渲染我们的组件

相关文章

网友评论

      本文标题:React 组件 & Props

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