我尝试使用 material-ui tabs => 固定选项卡 => 全宽选项卡面板 我有带标签的功能组件 OvertiemsReport:
const TabContainer = ({children, dir}) => (
<Typography component="div" dir={dir} style={{padding: 8 * 3}}>
{children}
</Typography>
);
const OvertimesReport = ({preview = false, tabValue, handleChange, classes}) => (
<div className={classes.workarea}>
<Card>
<CardContent className="overtimes">
<Typography variant="display2">Отчет о переработках</Typography>
<Grid container spacing={24} className={classes.gridContainer}>
<Grid item>
{preview}
<div className={classes.root}>
<AppBar position="static" color="default">
<Tabs
value={tabValue}
onChange={handleChange}
indicatorColor="primary"
textColor="secondary"
fullWidth
>
<Tab label="Item One"/>
<Tab label="Item Two"/>
</Tabs>
</AppBar>
</div>
</Grid>
</Grid>
</CardContent>
</Card>
</div>
);
而且我有外部handeChange函数
handleChange: value => dispatch(actions.handleChangeTab(value)),
并将值存储在 redux 中。
因此,在我单击更改选项卡后,在 handeChange 的输入中我收到了代理对象,而不是一些选择的选项卡
最佳答案
Tabs
组件的 onChange
属性的函数通过 event
和 value
调用为参数。
如果您将事件处理程序更改为这样,它将起作用:
handleChange: (event, value) => dispatch(actions.handleChangeTab(value)),
关于javascript - 在 material-ui/Tabs 中更改选项卡时是否有代理对象而不是索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51281192/