美文网首页
React 面向组件编程

React 面向组件编程

作者: 小仙有毒_1991 | 来源:发表于2021-12-14 12:01 被阅读0次

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

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

相关文章

网友评论

      本文标题:React 面向组件编程

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