【问题标题】:How to add tooltip to a disabled button using ReactStrap如何使用 ReactStrap 将工具提示添加到禁用的按钮
【发布时间】:2021-03-20 12:16:39
【问题描述】:

我有一个可以根据条件启用和禁用的按钮,我想将工具提示添加到禁用按钮。我不知道如何使用 reactstrap。

<Col sm={6}>
                  <Button
                    type="button"
                    id = {`button-${companyId}`}
                    disabled={
                      this.company[companyId] &&
                      this.company[companyId].length
                        ? false
                        : true
                    }
                    title = {this.company[company.id].length < 1? // As a makeover i Used title
                    "Not Active" : ""}
                    style={{ marginLeft: "-16px" }}
                    
                  >
                   </Button>
                    User list
                    {this.company[companyId].length < 1 ? (
                      <UncontrolledTooltip
                        target={`button-${companyId}`}
                        placement="bottom"
                        fade={false}
                      >
                        "Active"
                      </UncontrolledTooltip>
                    ) : null}
                  
                  </Col> 

但这不会向按钮添加工具提示。谁能建议我在这里做错了什么。

【问题讨论】:

    标签: reactjs reactstrap


    【解决方案1】:

    我建议你使用这样的条件;

    <Button 
    color="secondary" 
    size="lg" 
    disabled={(this.company[companyId] && this.company[companyId].length) ? false: true}>
    Button
    </Button>
    

    disabled={!(this.company[companyId] &amp;&amp; this.company[companyId].length)}&gt;

    【讨论】:

    • 好的,当然。但也请帮我在这个按钮上添加工具提示
    • 我不确定,但 reactstrap.github.io/components/tooltips 。这里有很好的文档。我在你的工具提示中看不到 isOpen 字段检查你双重检查工具提示的使用情况。
    • 我也试过这种方式,但对我帮助不大。我提到的方式适用于 fontawesome 图标但不适用于按钮。
    猜你喜欢
    • 2019-04-13
    • 1970-01-01
    • 2023-04-03
    • 2016-11-07
    • 2022-07-05
    • 2023-01-22
    • 2019-12-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多