Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 578 Bytes

函数式组件.md

File metadata and controls

23 lines (17 loc) · 578 Bytes
  1. 函数式组件
  2. 类式组件
// 1.创建函数式组件
function MyComponent() {
 console.log(this); //undefined
 return <h2>我是函数定义的组件(适用于【简单组件】的定义</h2>
}
// 2.渲染组件到页面
ReactDOM.render(<MyComponent/>, document.getElementById('test'))

// favicon.ico
/**

执行了ReactDOM.render(<>)...之后发生了什么?

1. React解析组件标签,找到了MyComponent组件
2. 发现组件式使用函数定义的,随后调用该函数,将返回的虚拟DOM转为真实DOM,随后呈现在页面中

 * /