【发布时间】:2019-02-23 01:34:11
【问题描述】:
我正在尝试使用 className“progress”来设置元素的样式,即使在尝试了许多可能性之后,我也无法为我的生活弄明白。
我能得到的任何帮助或提示将不胜感激!这是组件的代码:
constructor(props) {
super(props);
this.state = {
arrIterator: 0,
counter: 0,
sets: props.ids.sets,
exercises: props.program,
ids: props.ids
}
// Helper variable to decide when a new round starts --> Reset counter
this.newRoundOn = ((this.state.exercises.length /this.state.sets) -1);
// Gets percentage for progressbar
let barPercentage = ((this.state.arrIterator / this.state.exercises.length) * 100) +"%";
this.style = {
width: {barPercentage}
}
}
// Renders Progress Bar
renderProgressBar() {
return(
<div className="card-panel" id="progresjon-panel">
<div className="row">
<h5 className="col s8">Progresjon</h5>
<h5 className="col s4 right-align">{this.state.arrIterator +1} / {this.state.exercises.length}</h5>
</div>
<div className="progress" style={style}>
<div className="determinate"></div>
</div>
</div>
);
}
【问题讨论】:
-
style未定义。尝试将其更改为<div className="progress" style={this.style}。
标签: css reactjs progress-bar styling