我有这个功能设置
var $this = $(this);
if (msg == null) {
$this.tooltip('destroy');
}
else
{
$this.tooltip({'title': msg, 'placement': 'right', 'trigger': 'manual'});
$this.tooltip('show');
}
工具提示显示正常,销毁行抛出错误 data[option] is not a function
。如果我将其更改为 tooltip('hide')
,工具提示会自行隐藏,我无法将其自行删除。谁能帮我解决这个问题?
最佳答案
如果您没有输入错误,请检查您是否使用了最新版本的 Bootstrap javascript 插件。
tooltip.js 包含:
// TOOLTIP PLUGIN DEFINITION
// =========================
var old = $.fn.tooltip
$.fn.tooltip = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.tooltip')
var options = typeof option == 'object' && option
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]()
})
}
在 .tooltip('destroy');
的情况下 if (typeof option == 'string') data[option]()
给出了错误你提到如果 Tooltip.prototype.destroy
不存在。
关于javascript - Bootstrap Tooltip data[option] 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19027652/