react学习(46)----react渲染组件
生活随笔
收集整理的這篇文章主要介紹了
react学习(46)----react渲染组件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
const element = <div />;
不過,React 元素也可以是用戶自定義的組件:
const element = <Welcome name="Sara" />;當 React 元素為用戶自定義組件時,它會將 JSX 所接收的屬性(attributes)以及子組件(children)轉換為單個對象傳遞給組件,這個對象被稱之為 “props”。
例如,這段代碼會在頁面上渲染 “Hello, Sara”:
function Welcome(props) { return <h1>Hello, {props.name}</h1>; }const element = <Welcome name="Sara" />;ReactDOM.render(element,document.getElementById('root') );總結
以上是生活随笔為你收集整理的react学习(46)----react渲染组件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: K60学习笔记(三)——K60各模块概述
- 下一篇: 网页设计期末作品