gpt4 book ai didi

html - 如何在 React & Emotion 中将 2 个 css 变量附加到 JSX 元素

转载 作者:行者123 更新时间:2023-12-04 08:33:40 28 4
gpt4 key购买 nike

如何使用 Emotion 库将 style1 和 style2 附加到下面的 div?


const style1 = css`
display: flex;
`

const style2 = css`
width: 0;
`

const el= () => (
<div css={style1}>
)

最佳答案

在 Emotion 中,您可以执行所谓的 composition :

const style1 = css`
display: flex;
`

const style2 = css`
width: 0;
`

const el= () => (
<div
css={css`
${style1};
${style2};
`}
>
)

关于html - 如何在 React & Emotion 中将 2 个 css 变量附加到 JSX 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64907959/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com