【问题标题】:Is there a way to add a tooltip to the rating component on Material UI?有没有办法在 Material UI 的评分组件中添加工具提示?
【发布时间】:2021-08-09 13:42:39
【问题描述】:

我正在尝试为 Material UI [v4] 上评分组件的每个星添加一个工具提示,但我无法做到。

有没有办法在不使用其他评级库的情况下实现这一目标?

这些是我正在尝试实现的组件的链接:

https://material-ui.com/es/api/rating/ https://material-ui.com/es/api/tooltip/

提前致谢!

【问题讨论】:

    标签: reactjs material-ui tooltip


    【解决方案1】:

    提供一个自定义的IconContainerComponent 并在里面创建你自己的Tooltip

    <Rating
      IconContainerComponent = {
        function IconContainer(props) {
          // trigger your custom tooltip here
          const { value, ...other } = props;
          return <span {...other} />;
        }
      }
    />
    

    【讨论】:

      猜你喜欢
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-04
      • 2013-02-13
      • 2011-05-07
      • 1970-01-01
      • 2018-08-18
      相关资源
      最近更新 更多