第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 React 中創(chuàng)建帶有開始和結束標簽的 DOM 組件?

如何在 React 中創(chuàng)建帶有開始和結束標簽的 DOM 組件?

BIG陽 2023-09-07 10:10:47
在這里,我創(chuàng)建了一個組件SomeComponentconst SomeComponent = () => (    <div className={"some-class"}>        some text here    </div>)我可以像這樣使用這個組件:<SomeComponent text={"here is some text"} />我想做同樣的事情,但有一個開始和結束標簽,如下所示:<SomeComponent>    here is some text</SomeComponent>我怎樣才能做到這一點?
查看完整描述

3 回答

?
撒科打諢

TA貢獻1934條經驗 獲得超2個贊

您可以訪問“內容”作為children屬性。


const SomeComponent = ({ children }) => (

    <div className={"some-class"}>

      {children}

    </div>

)


查看完整回答
反對 回復 2023-09-07
?
慕娘9325324

TA貢獻1783條經驗 獲得超4個贊

您可以像這樣使用childrenprop :

const SomeComponent = ({ children }) => (

? ? <div className="some-class">

? ? ? ? {children}

? ? </div>

)

你可以這樣使用它:


<SomeComponent>whatever content here</SomeComponent>

childrenprop 不僅僅需要字符串,這些也可以工作:


<SomeComponent>

? <div>hey</div>

</SomeComponent>


<SomeComponent>

? {arrayOfComponents}

</SomeComponent>


查看完整回答
反對 回復 2023-09-07
?
POPMUISE

TA貢獻1765條經驗 獲得超5個贊

您所需要做的就是尋找children道具。


const SomeComponent = ({ children }) => (

    <div className="some-class">

        { children }

    </div>

);

子元素可以是文本、HTML 或其他 React 組件。


查看完整回答
反對 回復 2023-09-07
  • 3 回答
  • 0 關注
  • 142 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號