admin管理员组文章数量:1287849
I am trying to conditionally display a v-tooltip
based on a Boolean. This is what I have currently:
<div v-for="predefinedContentItem in getPredefinedContentCategoryItems(category.id)"
:class="['category-item-content-wrapper', { 'not-clickable': isMainDialogClosed}]"
v-tooltip.right="getPredefinedContentItemMessage(predefinedContentItem)"
slot="content"
:key="predefinedContentItem.id"
@click="onPredefinedContentItemClick(predefinedContentItem, category.id)">
I'm not trying to dynamically display different tooltip text. I want to determine whether or not to display the actual tooltip. I've tried the following ternary with no success:
<div v-for="predefinedContentItem in getPredefinedContentCategoryItems(category.id)"
:class="['category-item-content-wrapper', { 'not-clickable': isMainDialogClosed}]"
v-tooltip.right="isAutomotive ? getPredefinedContentItemMessage(predefinedContentItem) : null";
slot="content"
:key="predefinedContentItem.id"
@click="onPredefinedContentItemClick(predefinedContentItem, category.id)">
I am trying to conditionally display a v-tooltip
based on a Boolean. This is what I have currently:
<div v-for="predefinedContentItem in getPredefinedContentCategoryItems(category.id)"
:class="['category-item-content-wrapper', { 'not-clickable': isMainDialogClosed}]"
v-tooltip.right="getPredefinedContentItemMessage(predefinedContentItem)"
slot="content"
:key="predefinedContentItem.id"
@click="onPredefinedContentItemClick(predefinedContentItem, category.id)">
I'm not trying to dynamically display different tooltip text. I want to determine whether or not to display the actual tooltip. I've tried the following ternary with no success:
<div v-for="predefinedContentItem in getPredefinedContentCategoryItems(category.id)"
:class="['category-item-content-wrapper', { 'not-clickable': isMainDialogClosed}]"
v-tooltip.right="isAutomotive ? getPredefinedContentItemMessage(predefinedContentItem) : null";
slot="content"
:key="predefinedContentItem.id"
@click="onPredefinedContentItemClick(predefinedContentItem, category.id)">
Share
Improve this question
edited Aug 22, 2019 at 21:46
tony19
139k23 gold badges277 silver badges347 bronze badges
asked Aug 22, 2019 at 20:29
LDBLDB
6114 gold badges14 silver badges31 bronze badges
2
- 1 which library are you using ? or you're creating that directive by yourself? – Boussadjra Brahim Commented Aug 22, 2019 at 20:33
- Yea its v-tooltip... – LDB Commented Aug 22, 2019 at 20:38
2 Answers
Reset to default 5You can pass to v-tooltip
an object that takes extra options, and add the show
property inside the directive like this:
<div v-tooltip="{
content: getPredefinedContentItemMessage(predefinedContentItem),
show: isAutomotive,
trigger: 'hover',
placement: 'right',
}">
<div v-tooltip="{
content: isAutomotive ? getPredefinedContentItemMessage(predefinedContentItem) : null,
placement: 'right',
}">
本文标签: javascriptHow to conditionally display a tooltip in VuejsStack Overflow
版权声明:本文标题:javascript - How to conditionally display a tooltip in Vue.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741329232a2372672.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论