html - 如何在 React & Emotion 中将 2 个 css 变量附加到 JSX 元素
问题描述
如何使用 Emotion 库将 style1 和 style2 附加到下面的 div?
const style1 = css`
display: flex;
`
const style2 = css`
width: 0;
`
const el= () => (
<div css={style1}>
)
解决方案
在 Emotion 中,您可以执行所谓的组合:
const style1 = css`
display: flex;
`
const style2 = css`
width: 0;
`
const el= () => (
<div
css={css`
${style1};
${style2};
`}
>
)
推荐阅读
- android - 如何在持久的底页向上滑动时实现深色透明背景?
- mongodb - 当某些文档不包含路径时,mongo updateMany $set 嵌套数组
- python - QSqlQuery::exec:当我尝试在新数据库中创建表时数据库未打开
- python - 裁剪视频中的帧
- jquery - Select2 以编程方式更改数据
- c - 为什么编译器在这种情况下使用 32 位寄存器将指针传递给 amd64 linux 上的函数
- java - 是否可以使用接口作为验证人
- go - 如何从多部分格式中提取文件
- flutter - .toColor() 与增压颤振
- javascript - React loader 在“挂起”的 axios 请求期间不会保持可见