Antd | input.search-输入禁用,但请保持搜索按钮

发布于 2025-02-07 16:33:52 字数 350 浏览 2 评论 0 原文

我使用 input.search.search 禁用 Prop同时提供输入&禁用按钮。在禁用输入时,我想在这里启用按钮。

有解决方案吗?

<Search
  enterButton
  placeholder="ID"
  // disabled
  onSearch={() => console.log('search')}
/>

I use Input.Search. The disabled prop makes both the input & the button disabled. Here I want to keep the button enabled while the input is disabled.

Is there solution?

<Search
  enterButton
  placeholder="ID"
  // disabled
  onSearch={() => console.log('search')}
/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月棠 2025-02-14 16:33:52

使用 Enterbutton Prop&amp;提供自定义按钮组件。

const { Search } = Input;

const customButton = <Button type="primary" icon={<SearchOutlined />} />;

const onSearch = (value) => console.log(value);

const App = () => (
  <Space direction="vertical">
    <Search
      placeholder="input search text"
      enterButton={customButton}
      disabled
      size="large"
      onSearch={onSearch}
    />
  </Space>
);

在示例中,禁用了输入,但您可以单击“自定义搜索”按钮&amp;请参阅控制台日志。

Use enterButton prop & provide a custom button component.

const { Search } = Input;

const customButton = <Button type="primary" icon={<SearchOutlined />} />;

const onSearch = (value) => console.log(value);

const App = () => (
  <Space direction="vertical">
    <Search
      placeholder="input search text"
      enterButton={customButton}
      disabled
      size="large"
      onSearch={onSearch}
    />
  </Space>
);

In the example, input is disabled but you can click the custom search button & see the console logs.

Edit Search box - antd@4.21.2 (forked)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文