菜单
语言 & 框架

Styled components

NOT ON THE CURRENT EDITION
This blip is not on the current edition of the radar. If it was on one of the last few editions it is likely that it is still relevant. If the blip is older it might no longer be relevant and our assessment might be different today. Unfortunately, we simply don't have the bandwidth to continuously review blips from previous editions of the radarUnderstand more
Nov 2019
试验?

使用带标签的模板文字styled components,可以将为React组件设置样式所需的CSS直接放入创建该组件的JavaScript代码中。这大大减轻了管理CSS的痛苦,并且不需要为避免CSS中的命名冲突而想尽办法,比如命名约定等。开发人员在查看组件定义时可以直接看到样式,而不必记住几MB的CSS样式。当然,将CSS放入JavaScript代码中,可能会使跨不同组件样式的一致性变得更加困难,因此我们建议使用这种方法时一定要理解其优缺点。