样式
样式中的像素值
// Result style: '10px'
<div style={{ height: 10 }}>
Hello World!
</div>
// Result style: '10%'
<div style={{ height: '10%' }}>
Hello World!
</div>classnames 库的使用
import cx from 'classnames';
<div className={cx(
'header-left', // 最简单的类名
{loading: props.loading })}, // 属性值为true,才生成类名
`button-${props.color}`, // 传入属性生成动态类名,注意不传也会生成
{[`ts-${props.type}`]: props.type} // 属性值为true,才生成动态类名
/>cssModules
Last updated