class Parent extends React.Component{ constructor(){ super(); this.state={co:"red"} } render(){ return( <Child color={this.state.co}></Child> ) } } cl ...
分类:
其他好文 时间:
2019-09-03 22:21:49
阅读次数:
125
#include <iostream>class A {public: A() { std::cout << "A constructor!" << std::endl; } ~A() { std::cout << "A destructor!" << std::endl; }}; /* 全局对象, ...
分类:
编程语言 时间:
2019-09-03 11:46:17
阅读次数:
91
实现页面上两个DOM元素的操作,通过继承的方式 class Drag{ constructor(ele){ this.ele = ele; this.m = this.move.bind(this); this.u = this.up.bind(this); this.addEvent(); } a ...
分类:
其他好文 时间:
2019-09-02 09:32:21
阅读次数:
83
一、组件挂载阶段 1. componentWillMount() 该方法在首次渲染之前调用,在一个组件挂载到卸载的过程中,仅仅执行这一次。该函数内可以state初始化的工作,与constructor的作用类似。这里也是在render方法调用前最后一次修改state的方法。 这里不建议使用Ajax获取 ...
分类:
其他好文 时间:
2019-09-01 16:58:17
阅读次数:
95
一、typeof判断数据类型 由上图可知,数组类型Array,对象类型Object,null类型都返回了Object,所以应该细分。 二、instanceof判断某个引用是否属于某一个实例 三、constructor判断数据类型 constructo可以判断多种类型,在使用typeof时判断数组、对 ...
分类:
其他好文 时间:
2019-09-01 16:48:20
阅读次数:
68
一、创建对象的方式 1. new关键字,A a=new A(); 2. Constructor类的newInstance()方法,反射实现 3. Class类的newInstance()方法,内部还是调用Constructor类的newInstance()方法,反射实现 4. clone()方法,复 ...
分类:
编程语言 时间:
2019-09-01 12:41:25
阅读次数:
94
此对象非彼java bean对象 是scala object的对象 Object // object,相当于class的单个实例,通常在里面放一些静态的field或者method // 第一次调用object的方法时,就会执行object的constructor,也就是object内部不在metho ...
分类:
其他好文 时间:
2019-08-29 22:56:54
阅读次数:
100
类名和StringBuilder重复了。。。就近原则 ...
分类:
其他好文 时间:
2019-08-29 09:27:08
阅读次数:
58
java反射 反射是java的重要特性之一,java.lang.reflect 是jdk支持反射的重要包,我下面可能会对构造器Constructor,属性Filed,方法Method会用到。反射其实很常见,在java源码、spring就有很多运用,Spring AOP就应用到了反射。设计模式中代理模 ...
分类:
编程语言 时间:
2019-08-26 19:16:30
阅读次数:
102
"no-alert": 0,//禁止使用alert confirm prompt "no-array-constructor": 2,//禁止使用数组构造器 "no-bitwise": 0,//禁止使用按位运算符 "no-caller": 1,//禁止使用arguments.caller或argum... ...
分类:
其他好文 时间:
2019-08-26 15:28:05
阅读次数:
75