課程
/前端開發(fā)
/React.JS
/React高級(jí)教程之高階組件
B和C組件里面,B或者C都沒有定義,為什么可以調(diào)用
2019-07-30
源自:React高級(jí)教程之高階組件 2-3
正在回答
不好意思,剛剛看錯(cuò)了。老師應(yīng)該是忘記在b.js 和 c.js中 寫import A from './A';
代碼應(yīng)該如下:
A.js
import?React,?{PureComponent}?from?'react' export?default?WrapperComponent?=>?class?extends?PureComponent?{ ??render()?{ ????return?( ??????<div?className="App"> ????????<div?className="title">提示</div> ????????<WrapperComponent></WrapperComponent> ??????</div> ????); ??} };
B.js 與 C.js 代碼邏輯基本一樣
import?React,?{PureComponent}?from?'react' import?A?from?'./A'; export?default?A( ??class?extends?PureComponent?{ ????render()?{ ??????return?(<div>B組件</div>); ????} ??} );
App.js
import?React?from?'react'; import?B?from?'./components/B' import?C?from?'./components/C' import?'./App.css' function?App()?{ ??return?( ????<div?className="main"> ??????<B></B> ??????<C></C> ????</div> ??); } export?default?App;
家住海邊丶喜歡浪
b和c組件作為參數(shù)傳遞給A函數(shù)a函數(shù) 返回一個(gè)組件,其中將調(diào)用的參數(shù)? (此處是組件b或者c)進(jìn)行渲染
舉報(bào)
運(yùn)用高階組件編寫高質(zhì)量React應(yīng)用
5 回答B組件中的類名也是A嗎
3 回答C 組件 在哪? class 還是 A 啊?
1 回答css文件里面的 a-container 樣式都沒寫,a組件就渲染出來(lái)了?
1 回答這個(gè)和組合有什么區(qū)別
1 回答高階組件和props
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2019-08-04
不好意思,剛剛看錯(cuò)了。
老師應(yīng)該是忘記在b.js 和 c.js中 寫
import A from './A';
2019-10-16
代碼應(yīng)該如下:
A.js
B.js 與 C.js 代碼邏輯基本一樣
App.js
2019-08-04
b和c組件作為參數(shù)傳遞給A函數(shù)
a函數(shù) 返回一個(gè)組件,其中將調(diào)用的參數(shù)? (此處是組件b或者c)進(jìn)行渲染