React 面向组件编程

2021-12-14  本文已影响0人  小仙有毒_1991

函数式组件
// 创建函数式组件
function MyComponent() {
console.log(this)//this undefined 因为Babel开启了 严格模式
return <h1>我是用函数定义的组件</h1>
}

//渲染虚拟DOM
ReactDOM.render(<MyComponent/>,document.getElementById("container"))
上一篇 下一篇

猜你喜欢

热点阅读