摘要: contructor 开始: getDefaultProps-->getInitialState-->componentWillMount-->render-->compononentDidMount props发生变化: componentWillReciveProps-->shouldCompo 阅读全文
posted @ 2021-07-06 13:21 baixinL 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 一个组件的显示形态由数据状态state和外部参数props所决定。 state和props 不同之处,state是可以被改变的,使用setState 和useState中定义的setxxx改变值,都是异步的。 state主要作用是: 用于组件保存、控制以及修改自己的状态; 它只能在contructo 阅读全文
posted @ 2021-07-06 12:59 baixinL 阅读(66) 评论(0) 推荐(0) 编辑
摘要: react的核心思想是组件化思想,页面被分割成一个个独立可复用的组件。 组件化从概念上看就是一个函数,可以接受参数作为输入值,这个参数就是props,props可以理解成从外部传入组件内部的数据。 由于react是单向数据流,所以props基本上也就是从父级组件向子组件传递的数据。 阅读全文
posted @ 2021-07-06 12:48 baixinL 阅读(643) 评论(0) 推荐(0) 编辑
摘要: render 方法 返回一个根节点的jsx 这个jsx是最后转义后html渲染到html,就是js写的html. 阅读全文
posted @ 2021-07-06 12:41 baixinL 阅读(116) 评论(0) 推荐(0) 编辑