javascript - 如何将material-ui按钮样式应用于html-native按钮
问题描述
pure-react-carousel给了我一个无样式的 html 按钮 ( ButtonBack
),我想使用material-ui来设置它的样式。
不允许在按钮内放置按钮。
有效的是手动分配 className 道具:
<ButtonBack className={"MuiButtonBase-root MuiButton-root MuiButton-contained"}>
<NavigateBeforeIcon />
</ButtonBack>
但感觉不对,而且渲染效果不如真正的 Mui-Button。
当然,我可以编写自己的模仿 Muis 的 css,但这也感觉不对。
有没有更简单/直接的方法来解决这个问题?
解决方案
import { ButtonFirst } from 'pure-react-carousel';
import Button from '@material-ui/core/Button';
const CustomButtonFirst = React.forwardRef((props, ref) => <Button component={ButtonFirst} ref={ref} {...props} />);
// This line is needed because the "disabled" is internal state of "ButtonFirst".
export default withStore(CustomButtonFirst, state => ({ disabled: state.currentSlide === 0 }));
取自: https ://github.com/express-labs/pure-react-carousel/issues/175
推荐阅读
- android - 如何通过从 /asset/location 读取 Json 文件来制作动态页面
- django - 我看不懂这段代码也不知道怎么用?
- excel - 有基于公式中的公式的区域参考
- java - 如何使用 apache-commons-csv 在 .csv 文件中添加一列
- sql - 如何将 .NET DateTime 转换为 SQL Datetime?
- docker - 无法在 Ubuntu 中安装 Docker
- vbscript - 如何使用 UNC 路径进行 WMI 事件监控
- .net - 使用 Microsoft.Extensions.Hosting.WindowsServices 时无法启动 Windows 服务
- ios - UICollectionViewLayout sectionInset 不起作用
- c - 为什么我一直覆盖我在链接列表中指向的内容?