摘要:
React生命周期分为3个阶段 挂载时 首先会调用 constructor 创建组件,这里可以通过 props 接收父组件传递过来的数据,可以通过 this.state 初始化组件自己的数据 然后调用 render 渲染组件,主要是返回组件的结构 当组件渲染完毕后调用 componentDidMou 阅读全文
posted @ 2021-12-04 23:31
霸哥yyds
阅读(48)
评论(0)
推荐(0)
摘要:
子组件将数据传递给父组件 import React from 'react'; class Son extends React.Component { constructor(props) { super(props); this.state = { name: 'xiebenyin' } } re 阅读全文
posted @ 2021-12-04 15:03
霸哥yyds
阅读(46)
评论(0)
推荐(0)
摘要:
跨组件通信 import React from 'react'; // 创建上下文件对象 const Context = React.createContext({}); // 从上下文中获取容器组件 // Provider 生产者容器组件 负责生产数据 // Consumer 消费者容器组件 负责 阅读全文
posted @ 2021-12-04 14:29
霸哥yyds
阅读(46)
评论(0)
推荐(0)

浙公网安备 33010602011771号