【发布时间】:2018-12-31 16:40:34
【问题描述】:
这些步骤采用 steps 数组的长度数字,即
state = {
steps: [0, 1, 2, 3]
};
以后这个状态可能会变成
this.setState({
steps: [1,2,3,4]
});
或者
this.setState({
steps: [2,3,4,5]
});
等等……
但在所有情况下,我的步骤仅显示 1、2、3、4。我需要根据步骤的数组元素更改这些数字。
这是步进器的代码。
<Stepper alternativeLabel nonLinear activeStep={activePage}>
{steps.map((step, index) => {
return (
<Step key={index}>
<StepButton
onClick={this.handleStep(index)}
disabled={dealsLoading}
>
</StepButton>
</Step>
);
})}
</Stepper>
如何做到这一点?
但我不想要标签。我希望这些标签应该在步骤按钮上。 代码:
<Stepper alternativeLabel nonLinear activeStep={activePage}>
{steps.map((step, index) => {
return (
<Step key={index}>
<StepLabel
onClick={this.handleStep(step)}
disabled={dealsLoading}
>
{step}
</StepLabel>
</Step>
);
})}
</Stepper>
【问题讨论】:
标签: reactjs material-ui stepper