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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

不是樣式組件的 React 樣式可重用組件

不是樣式組件的 React 樣式可重用組件

瀟湘沐 2021-10-21 15:04:31
我有一個(gè)可重用的組件,其中包含一個(gè)名為 AnimationLoader 的動(dòng)畫。該組件是用于加載狀態(tài)的可重用組件。我只是想獲取這個(gè)組件并在另一個(gè)組件中使用它,UnpublishBlogBtn 作為單擊按鈕后的加載程序 - 一切正常。但是,我想更改 UnpublishBlogBtn 中動(dòng)畫的高度和寬度,但我一生都無法使其正常工作。我已經(jīng)嘗試實(shí)現(xiàn) Object.assign 以從另一個(gè)文件中引入 CSS 并更改高度和寬度。我還嘗試通過<style={{}}>將組件包裝在添加了樣式的 div 中來更改 CSS (這似乎只是更改按鈕而不是動(dòng)畫本身)。<Button type="main" className="blogBtn">   {currentlyUnpublishingBlog ? <AnimatedLoader css={{ height: 1, width: 1 }}/> :    'Unpublish Blog'}</Button>const AnimatedLoader = () => {  return (    <div      css={{        height: 45,        width: 45      }}    >      <AnimatedIcon         css={{          animationDelay: '0.7s',          height: 35,          left: 10,          position: 'absolute',          top: 10,          width: 35        }}      />      <AnimatedIcon         css={{          animationDelay: '0.7s'          display: 'none',          height: 45,          left: 0,          top: 0,          width: 45,        }}      />      <div        css={{          borderRadius: 20,          borderStyle: 'solid',          borderWidth: 3,          height: 45,          position: 'absolute',          width: 45,        }}      />    </div>  )};export default AnimatedLoader;用戶單擊取消發(fā)布博客按鈕后,加載程序應(yīng)在按鈕頂部顯示較小的寬度和高度。目前,它保持與 AnimatedLoader 組件內(nèi)列出的大小相同的大小,我希望在 UnpublishBlogBtn 組件內(nèi)更改大小。
查看完整描述

1 回答

?
有只小跳蛙

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超8個(gè)贊

您可以將您的css輸入作為道具傳遞給您的AnimatedLoader


 const AnimatedLoader = ({css={

        height: 45,

        width: 45

      }}) => {

  return (

    <div

      {...css}

    >

      <AnimatedIcon 

        css={{

          animationDelay: '0.7s',

          height: 35,

          left: 10,

          position: 'absolute',

          top: 10,

          width: 35

        }}

     // ....

如果您需要做更復(fù)雜的事情,傳入一個(gè)將不同樣式選項(xiàng)描述為一個(gè)組的 prop 可能更明智。因此,isSmallSize作為布爾值或不同大小作為枚舉等。


然后在您的組件中根據(jù)道具調(diào)整樣式。


const AnimatedLoader = ({ isSmallSize = false }) => {

    const outerSize = isSmallSize ? 

                       { height: 45, width: 45 } : { height: 1, width: 1 }

    const iconSize = isSmallSize ? 

                       { height: 35, width: 35 } : { height: 1, width: 1 }

    return (

       <div css={{ ...outerSize }}>

         <AnimatedIcon

           css={{

             animationDelay: '0.7s',

             left: 10,

             position: 'absolute',

             top: 10,

             ...iconSize

           }}

         />

         <AnimatedIcon

           css={{

             animationDelay: '0.7s',

             display: 'none',

             left: 0,

             top: 0,

             ...iconSize

           }}

         />

         <div

           css={{

             borderRadius: 20,

             borderStyle: 'solid',

             borderWidth: 3,

             position: 'absolute',

             ...iconSize

           }}

      />

    </div>

  )

}



查看完整回答
反對(duì) 回復(fù) 2021-10-21
  • 1 回答
  • 0 關(guān)注
  • 192 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)