问题描述
我直接从 tippy.js documentation 拿了这个例子:
<button id="myButton">My Button</button>
tippy('#myButton',{
content: "I'm a Tippy tooltip!",});
我似乎无法使 content
选项起作用;但是如果我在 button 元素中添加了 title 属性,就会出现提示框!
解决方法
按钮上的
title
属性是 HTML 按钮元素的默认行为。
您是否包含脚本?我尝试了以下方式(如文档中所述)并且它没有任何问题。
<button id="myButton">My button</button>
<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>
<script>
// With the above scripts loaded,you can call `tippy()` with a CSS
// selector and a `content` prop:
tippy('#myButton',{
content: 'My tooltip!',});
</script>