Ham*_*mid 4 reactjs material-ui
我在 React 项目中使用 material-ui,现在我想展示一个步进器。但我不想要按钮来逐步向后和向前。我希望所有步骤都一起活跃。
import React from 'react';
import Stepper from '@material-ui/core/Stepper';
import Step from '@material-ui/core/Step';
import StepLabel from '@material-ui/core/StepLabel';
import StepContent from '@material-ui/core/StepContent';
import Typography from '@material-ui/core/Typography';
function getSteps() {
return ['Title 1', 'Title 2', 'Title 3'];
}
function getStepContent(step) {
switch (step) {
case 0:
return `For each ad campaign that you create, you can control how much
you're willing to spend on clicks and conversions, which networks
and geographical locations you want your ads to show on, and more.`;
case 1:
return 'An ad group contains one or more ads which target a shared set of keywords.';
case 2:
return `Try out different ad text to see what brings in the most customers,
and learn how to enhance your ads using features like ad extensions.
If you run into any problems with your ads, find out how to tell if
they're running and how to resolve approval issues.`;
default:
return 'Unknown step';
}
}
class VerticalLinearStepper extends React.Component {
render() {
const steps = getSteps();
return (
<div className={classes.root}>
<Stepper orientation="vertical">
{steps.map((label, index) => {
return (
<Step key={label} active={true}>
<StepLabel>{label}</StepLabel>
<StepContent>
<Typography>{getStepContent(index)}</Typography>
</StepContent>
</Step>
);
})}
</Stepper>
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
我想要的是在没有任何用于后退和前进的按钮的情况下一起查看所有步骤内容。但我只能看到第一步的内容,因为activestep“Stepper”的 prop的默认值为0。
| 归档时间: |
|
| 查看次数: |
1880 次 |
| 最近记录: |