You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

react-bootstrap-typeahead替换ClearButton为CloseButton后点击失效且有图形bug

问题描述

我在使用react-bootstrap-typeahead提供的ClearButton时遇到了图形显示bug,于是尝试用Bootstrap的CloseButton替换,但替换后的CloseButton无法触发点击事件。

图形bug截图:
ClearButton图形显示异常

代码实现

import { CloseButton } from "react-bootstrap";
import { Typeahead, ClearButton } from "react-bootstrap-typeahead";
import "bootstrap/dist/css/bootstrap.min.css";
import "react-bootstrap-typeahead/css/Typeahead.css";

<Typeahead
      id="search"
      options={chartData.datasets}
      labelKey={chartData.datasets.label}
      placeholder="look for projects"
      multiple
      onChange={setMultiSelections}
      selected={multiSelections}
    >
      {({ onClear, selected }) => (
        <div className="rbt-aux">
          {!!selected.length && <CloseButton onClick={onClear} />}
        </div>
      )}
</Typeahead>

已尝试的操作

  • 修改rbt-close-content CSS类样式
  • 替换样式文件为react-bootstrap-typeahead/css/Typeahead.bs5.css

请问我哪里操作有误?


内容的提问来源于stack exchange,提问作者lejanus12

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 05:10:43