摘要: <script type="text/babel"> //1.创建类式组件 class MyComponent extends React.Component { render(){ //render是放在哪里的?—— MyComponent的原型对象上,供实例使用。 //render中的this是 阅读全文
posted @ 2021-04-20 14:57 大海啊都是水啊水 阅读(122) 评论(0) 推荐(0)
摘要: <script type="text/babel"> //1.创建函数式组件 function MyComponent(){ console.log(this); //此处的this是undefined,因为babel编译后开启了严格模式 return <h2>我是用函数定义的组件(适用于【简单组件 阅读全文
posted @ 2021-04-20 14:49 大海啊都是水啊水 阅读(360) 评论(0) 推荐(0)
摘要: <script type="text/babel" > const myId = 'aTgUiGu' const myData = 'HeLlo,rEaCt' //1.创建虚拟DOM const VDOM = ( <div> <h2 className="title" id={myId.toLowe 阅读全文
posted @ 2021-04-20 13:37 大海啊都是水啊水 阅读(45) 评论(0) 推荐(0)