Bootstrap工具提示不显示 [英] Bootstrap Tooltip Not Showing Up
问题描述
我正在尝试在我的应用程序中使用Bootstrap 工具提示。目前,我有以下内容:
I am trying to use the Bootstrap tooltip in an app of mine. Currently, I have the following:
<button type="button" class="btn btn-default"
data-toggle="tooltip" data-placement="left"
title="Tooltip on left">
Tooltip on left
</button>
不幸的是,我的工具提示没有显示。我想弄清楚我做错了什么。我知道它可以通过JavaScript创建。但是,我正在尝试以声明方式定义我的工具提示。我已经确认包含了Tooltip.js文件。但是,我无法弄清楚我做错了什么。
Unfortunately, my tooltip is not showing. I'm trying to figure out what I'm doing wrong. I know that it can be created via JavaScript. However, I'm trying to define my tooltip declaratively. I've confirmed that the Tooltip.js file is being included. However, I can't figure out what I'm doing wrong.
是否可以在纯粹的声明意义上使用工具提示?如果是这样,有人可以通过JSFiddle或Bootply样本向我展示如何?我真的很喜欢这个。
Is it possible to use a tooltip in a pure declarative sense? If so, can someone show me how via a JSFiddle or Bootply sample? I'm really banging my head on this one.
推荐答案
不,不可能在纯粹的声明中使用工具提示感。来自文档:
No, it is not possible to use the tooltip in a pure declarative sense. From the Docs:
选择加入功能
出于性能原因,工具提示和弹出式数据apis是选择加入的,这意味着您必须自己初始化它们。
Opt-in functionality:
For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.
所以你必须在JavaScript中手动调用 .tooltip()
,如下所示:
So you must call .tooltip()
manually in JavaScript like this:
$("[data-toggle=tooltip]").tooltip();
或者使用你想要的任何选择器。
Or use whatever selector you want.
这应该是这样的:
这篇关于Bootstrap工具提示不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!