2022
04-20
04-20
react组件中的constructor和super知识点整理
1、react中用class申明的类一些小知识如上图:类Child是通过class关键字申明,并且继承于类React。A、Child的类型是?typeofChild==='function',其实就相当于ES5用function申明的构造函数functionChild(){//申明构造函数}B、Child类调用时候(newChild()),会优先执行,并且自动执行Child的constructor函数。constructor(){console.log('执行了constructor')return'hah'}getName(){console...
继续阅读 >