javascript - 如何在画布内的fabricjs对象上触发tippyjs工具提示
问题描述
我正在尝试在 FabricJS 画布上使用 TippyJS 创建一些工具提示,但不断收到我使用的选择器无效的错误。
通常这是我使用 Tippy 触发工具提示的方式:
$( ".hoverimagetip" ).each(function( i ) {
tippy(this, {
theme: 'blue',
trigger: 'mouseenter',
allowHTML: true,
followCursor: 'initial',
animation: 'scale-subtle',
interactive: true,
content: function (reference) {
return reference.querySelector('.tooltipcontent');
}
});
});
但是现在我想在单击画布内的对象时触发工具提示,在这种情况下cirkel1
,我尝试了以下操作(在创建 cirkel1 并将其添加到画布之后):
cirkel1.on('mousedown', ()=>{
tippy(this, {
theme: 'blue',
trigger: 'mouseenter',
allowHTML: true,
followCursor: 'initial',
animation: 'scale-subtle',
interactive: true,
content: function (reference) {
return reference.querySelector('.tooltipcontent');
}
});
});
但是当单击圆圈时,我在控制台中收到此错误:
tippy.js@6:1 Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': '#<fabric.Circle>' is not a valid selector.
这样做的正确方法是什么?
带有完整代码的 Codepen: https ://codepen.io/twan2020/pen/mdOWgaG
解决方案
推荐阅读
- javascript - 在 JS 中突出显示纯 html
- mysql - MySQL 在日期之间搜索,但也在时间范围之间搜索
- javascript - 使用 requestAnimationFrame 而不是 setInterval
- php - 如何更改和抑制 JSON 结果中的某些字段键名?
- postgresql - 如何完全删除postgres?
- ios - 从 SWIFT 4.1 中的 Firebase 检索数据时,“下标”的模糊使用和无法调用非函数类型“AnyObject”的值错误
- python - 对于在文本中搜索单词的快速 python 包有什么建议吗?
- crystal-reports - Crystal Reports:两个表并排,来自一个查询 BEx
- rest - 如何让 PowerBI 使用受访问令牌保护的我的 RESTful 服务?
- twitter-bootstrap - 电话上的引导网格系统意外结果