javascript - 选项卡显示在抽屉中,但没有发生切换
问题描述
- 我是材料ui的新手。
- 当您单击高级体育搜索时,会打开一个抽屉。
- 我正在尝试在抽屉中实现选项卡,但是当我单击抽屉中的两个选项卡时,它会关闭。
- 实际上它应该在选项卡之间切换。
- 它在初始页面上工作。
- 所以我调试了handleChange方法,它在初始页面和打印控制台上工作正常---> console.log("switch tabs inital page--->");
- 当我调试抽屉选项卡时,它的打印控制台但不切换选项卡---> console.log("switch tabs drager ui--->");
- 你能告诉我如何解决它。
- 在下面提供我的代码片段。
https://codesandbox.io/s/1qlpxx34v3
handleChange = (event, value) => {
console.log("switch tabs drager ui--->");
this.setState({ value });
};
<Tabs
value={value}
onChange={this.handleChange}
scrollable
scrollButtons="on"
indicatorColor="primary"
textColor="primary"
>
<Tab label="Item One" icon={<PhoneIcon />} />
<Tab label="Item Two" icon={<FavoriteIcon />} />
</Tabs>
解决方案
On line 222 in tab-demo.js
, I commented out this line:
onClick={this.toggleDrawer("right", false)}
Because with that line, every time you click inside the drawer, it will close.
推荐阅读
- css - 反应应用程序中的复杂布局:CSS 或 Bootstrap,或两者兼而有之?
- kotlin - Dagger 不支持注入私有字段
- python - 使用 Python Selenium 点击垃圾邮件
- google-sheets - 如果一个过滤范围没有匹配项,则查询两个过滤范围不显示任何结果
- virtual-machine - 将.ova文件导入VirtualBox后可以删除吗?
- javascript - 单击图像后如何使CSS动画发生
- bash - 使用 awk 将带空格的第一列视为一列
- mysql - 用于 Node.Js 的 Mysql2 是否需要在执行 queires 之前在 mysql.CreateConnection 上运行 connect()
- angular - 角度路由添加随机滚动条
- java - CompilingClassLoader 很有趣,在这种情况下如何从不同的类加载器加载子类?