【发布时间】:2017-07-18 22:14:47
【问题描述】:
我创建了一个反应组件,它采用一个数组并将所有进度条堆叠成一个。
const ProgressBar = (props, {...customProps}) => {
const GroupProgressBar = [];
props.groups.map((group, i) => {
const widthValue = (group.value / group.max) * 100;
GroupProgressBar.push
(<div style={{width: `${widthValue}%`}}
key = {i}
className={`well-background--${group.concept}
animation
terra-ProgressGroup--progress
terra-ProgressBar--${props.heightSize}`}>
</div>);
})
return <div className='terra-ProgressGroup'> {GroupProgressBar} </div>
}
CSS(下面的类我想转换为单个类):
....
.well-background--concept1 {
animation-delay: 1s;
z-index: -1;
}
.well-background--concept2 {
animation-delay: 2s;
z-index: -2;
}
.well-background--concept3 {
animation-delay: 3s;
z-index: -3;
}
我试图将这些类转换为一个,但没有运气
:root {
--concept-code: key;
--concept-code2: key;
}
.animation {
animation-delay: var(--concept-code)s;
z-index: var(--concept-code2);
}
基本上我不想继续添加那些类似的类,所以我试图创建一个类并从反应组件传递这些数字。可能使用key = {i}
我怎样才能做到这一点?
【问题讨论】:
标签: reactjs react-redux jsx