自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(6)
  • 收藏
  • 关注

原创 redux原理图

2021-04-18 00:34:34 332

原创 react新版本的生命周期钩子用法

getDerivedStateFromProps()会在render之前调用,并且会在初始页面也后续更新时都会调用,若返回一个对象则会更新state,若返回null也不做任何更新。当state在任何时刻都取决于props时可以在该钩子中对props和state进行对比判断,因为可以接受props和state两个参数。当state的值依赖props时需要使用当前钩子函数。static getDerivedStateFromProps(props, state){ console.log('getD.

2021-04-15 15:25:15 104

原创 react组件之间的订阅发布

利用Pubsub-js包进行组件之间(包括兄弟组件、远亲组件)的数据传递import Pubsub from 'pubsub-jsclass A extends React.Component { Pubsub.publish('myData',data) render(){ return ( <div></div> ) }}---------------------------------------------import Pubsub from '

2021-04-15 15:24:44 90

原创 react生命周期钩子

2021-04-13 00:33:33 71

原创 react中ref的三种形式

字符串形式(不推荐)class Demo extends React.Component { showDate = () => { const {input1} = this.refs alert(input1.value) } showData2 = () => { const {input2} = this.refs alert(input2.value) } render(){ <div> <input ref='input1'/&g.

2021-04-12 15:28:09 360

原创 react中constructor构造器的使用

react的constructor构造器中的使用在react类组件内使用constructor构造器一般两种用途,应在其他语句之前使用super(props),否则在构造器内若要获取this.props会出现未定义。对state状态进行初始赋值在constructor内不应使用setState来改变state,应直接对this.state进行赋值class Person extends React.Components { constructor(props){ super(props)

2021-04-12 13:31:25 1026

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除