const instance = tippy(' .tooltippy' , {
trigger: 'mouseenter',
allowHTML: true,
placement: 'left',
animation: 'scale-subtle',
interactive: true,
content: function (reference) {
return reference.querySelector(' .tooltipcontent')。
}
});
setTimeout(function() {
instance.show()。
},5000)。)
但5秒后我得到:
Uncaught TypeError: instance.show不是一個function>。
而我的tippyjs作業正常。
我的HTML:
< span class="whatsappicon tooltippy" title="Chat met ons! ">
<span class="whaplabel tooltipcontent"/span>>Stel je vraag! </span>/span>Stel je vraag!
< a href="url" target="_blank">
<img src="images/custom/whatsapp_online. png" alt="Open Whatsapp">。
</a>/span>
</span>
我怎樣才能在5秒后打開這個小費?
uj5u.com熱心網友回復:
更新了我的問題,因為我沒有看到你把它直接分配給一個HTMLCollection。Tippy需要與NodeList或Element型別系結,所以我們需要先獲得元素并將其分配給它。
這個例子應該是可行的:
。const tooltippy = document. getElementById('tooltippy')
const instance = tippy(tooltippy, {
trigger: 'mouseenter',
allowHTML: true,
placement: 'left',
animation: 'scale-subtle',
interactive: true,
content: function (reference) {
return reference.querySelector(' .tooltipcontent')。
}
});
setTimeout(function() {
instance.show()。
}, 5000);
<script src="https://unpkg. com/@popperjs/core@2/dist/umd/popper.min.js">/span></script>/span>
<script src="https://unpkg.com/tippy.js@6/dist/tippy-bundle.umd.js"/span>> </script>>
< span class="whatsappicon"/span> id="tooltippy" title= "Chat met ons! ">
<span class="whaplabel tooltipcontent"/span>>Stel je vraag! </span>/span>Stel je vraag!
< a href="url" target="_blank">
<img src="images/custom/whatsapp_online. png" alt="Open Whatsapp">。
</a>/span>
</span>/span>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/333737.html
標籤:
上一篇:從服務類呼叫方法時,SpringBoot@AutowiredNullPointerException
下一篇:實作從url獲取路徑變數的投票者
