【问题标题】:How to disable long click effect on a material-ui button?如何禁用material-ui按钮的长按效果?
【发布时间】:2021-09-23 23:24:41
【问题描述】:

我有这个带有图标的 btn,我点击了很长时间,它在图标周围产生了不希望的效果,任何线索如何删除此操作?

import React from "react";
import ReactDOM from "react-dom";
import Button from "@material-ui/core/Button";
import ViewListIcon from "@material-ui/icons/ViewList";

function App() {
  return (
    <div>
      <Button style={{ MuiButtonBase: { disableRipple: true } }}>
        <ViewListIcon />
      </Button>
    </div>
  );
}

ReactDOM.render(<App />, document.querySelector("#app"));

CodeSandbox

【问题讨论】:

  • 我想你说的是连锁反应。要禁用波纹,您需要将 disableRipple 属性传递给 Button 组件 (Not as a style)HereButton 组件可用 props 的 API。更新后的sandbox
  • 请提交答案。
  • 这能回答你的问题吗? How to disable ripple in Material Design React
  • 以上评论中的这个link有更好的答案。

标签: material-ui


【解决方案1】:

disableRipple 属性添加到Button

<Button disableRipple>
  <ViewListIcon />
</Button>

【讨论】:

  • 这个答案被标记为低质量,请提供更多支持信息和解释来更好地回答
猜你喜欢
  • 2018-10-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-19
  • 1970-01-01
  • 1970-01-01
  • 2016-08-31
相关资源
最近更新 更多