简体   繁体   English

Bootstrap React 工具提示不适用于 p 或 span 标签仅适用于按钮?

[英]Bootstrap React tooltip not working with p or span tag only work with button?

I want a tooltip on the span or p tag but to me this only works on the Button tag.我想要 span 或 p 标签上的工具提示,但对我来说,这只适用于 Button 标签。 I am using plugin SortableTree but that is not important more:我正在使用插件 SortableTree 但这并不重要:

                <SortableTree
                  nodeContentRenderer={NodeRenderer}
                  treeData={treeDataFirst}
                  onMoveNode={() => this.test()}
                  onChange={(treeDataFirst) =>
                    this.setState({ treeDataFirst })
                  }
                  isVirtualized={false}
                  canDrag={false}
                  generateNodeProps={({ node, path }) => {
                    return {
                      title: (
                        <OverlayTrigger
                          placement="right"
                          overlay={node.title}
                          id={`id${node}`}
                        >
                          <Button> 
                            {node.title} 
                          </Button>
                        </OverlayTrigger>
                      ),
                      id: "left-tree", 
                    };
                  }}
                />

Here work but when set..在这里工作,但当设置..

                <SortableTree
                  nodeContentRenderer={NodeRenderer}
                  treeData={treeDataFirst}
                  onMoveNode={() => this.test()}
                  onChange={(treeDataFirst) =>
                    this.setState({ treeDataFirst })
                  }
                  isVirtualized={false}
                  canDrag={false}
                  generateNodeProps={({ node, path }) => {
                    return {
                      title: (
                        <OverlayTrigger
                          placement="right"
                          overlay={node.title}
                          id={`id${node}`}
                        >
                          <span>  // OR <p> TAG NO WORK
                            {node.title} 
                          </>>
                        </OverlayTrigger>
                      ),
                      id: "left-tree", 
                    };
                  }}
                />

how do i fix this?我该如何解决?

I want the hover p tag to show me the text我希望 hover p 标签显示文本

I am using React Bootstrap tooltip Overlay..我正在使用 React Bootstrap 工具提示 Overlay..

In ReactBootstrap docs it has documented how to customize overlaytrigger在 ReactBootstrap 文档中,它记录了如何自定义叠加触发器

https://react-bootstrap.netlify.app/components/overlays/#customizing-trigger-behavior https://react-bootstrap.netlify.app/components/overlays/#customizing-trigger-behavior

Playing a bit there i founded out that you would need to pass ref and triggerHandler props to your span tag.在那里玩了一下,我发现您需要将reftriggerHandler道具传递给您的 span 标签。

render(
  <OverlayTrigger
    placement="bottom"
    overlay={<Tooltip id="button-tooltip-2">Check out this avatar</Tooltip>}
  >

// use ref and triggerHandler
    {({ ref, ...triggerHandler }) => (
        <span className="ms-1" ref={ref} {...triggerHandler}>Hover to see</span>
    )}
  </OverlayTrigger>,
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载Img标签(子级)的Span标签(父级)中的Bootstrap工具提示 - Bootstrap Tooltip in Span Tag (parent) of Img tag (child) failing to load bootstrap工具提示/弹出按钮不起作用 - bootstrap tooltip/popover on a button not working 如何获得只有<p>标签文本,包括<span>标签</span></p> - How to get only <p> tag text including <span> tag 将单词列表呈现为<span>a</span><p> <span>React js 中的标签</span> - Render list of words as <span> in a <p> tag in React js Bootstrap 4 工具提示隐藏在按钮单击时不起作用? - Bootstrap 4 tooltip hide is not working on button click? Bootstrap data-toggle =“按钮”无法使用 - Bootstrap data-toggle=“button” not working with <span> React-Bootstrap ONLY 关闭按钮样式不起作用 - React-Bootstrap ONLY Close Button Styling Not Working 如何使用span标签和glyphicon而不是bootstrap上的按钮制作下拉菜单? - How to make a dropdown menu with span tag and glyphicon instead of button on bootstrap? 如何将 class(基于 if - else 的结果)动态分配给使用 Bootstrap Tagsinput 的弹出工具提示的 span 标签 - How to dynamically assign a class (based on the outcome of if - else) to a span tag of a popover tooltip that uses Bootstrap Tagsinput 模态形式 label 标签内的引导工具提示不起作用 - Bootstrap tooltip within modal form label tag not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM