--- PART 1: v-tooltip ----
According to the vuetify documention on v-toolip
This is how to correctly use v-tooltip;
<template>
<div>
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<v-btn
color="secondary"
dark
v-bind="attrs"
v-on="on"
>
Test Button
</v-btn>
</template>
<ul style="list-style: none;">
<li> <img :src="contains_eight_characters">8 characters</li>
<li> <img :src="contains_number">1 number</li>
<li> <img :src="contains_uppercase">1 upper case</li>
<li> <img :src="contains_lowercase">1 lower case</li>
<li> <img :src="contains_special_character">1 special character</li>
</ul>
</v-tooltip>
</div>
</template>
Working demo: demo
The activator slot should contain the item which the tooltip should appear when hovering over. You need to bind the attrs and the on provided by the slot scope to whatever is inside the activator.
Make sure to replace "top" with any direction (top | bottom | left | right) that you want.
---- PART 2: Binding the image sources ----
You can use v-bind in the template. Look at the official Vue documentation to learn more.
Assuming this is some sort of password requirements tooltip (where you decide which image to show based on whether the condition is true or false);
- Make two variables - one for each image type
- Bind each image source to a computed property for the condition returning one variable or the other
- Profit
Variables (sorry I will be using Vue 3 syntax here I don't know if you're using Vue 2 or 3);
<script setup>
import { ref, computed } from "vue";
...
// You also need a variable containing your password field binded value
const passwordValue = ref("");
const metConditionImage = "@/assets/images/v-icon.svg";
const unmetConditionImage = "@/assets/images/x-icon.svg";
const containsNumber = computed(() => {
... implement here
return INSERTYOURCONDITIONHERE ? metConditionImage : unmetConditionImage;
});
const containsEightCharacters = computed(() => {
... implement here
return INSERTYOURCONDITIONHERE ? metConditionImage : unmetConditionImage;
});
const containsUppercase = computed(() => {
... implement here
return INSERTYOURCONDITIONHERE ? metConditionImage : unmetConditionImage;
});
const containsLowercase = computed(() => {
... implement here
return INSERTYOURCONDITIONHERE ? metConditionImage : unmetConditionImage;
});
const containsSpecialCharacter = computed(() => {
... implement here
return INSERTYOURCONDITIONHERE ? metConditionImage : unmetConditionImage;
});
</script>
Binding the imageSources to the computed properties;
<li> <img :src="containsEightCharacters">8 characters</li>
<li> <img :src="containsNumber">1 number</li>
<li> <img :src="containsUppercase">1 upper case</li>
<li> <img :src="containsLowercase">1 lower case</li>
<li> <img :src="containsSpecialCharacter">1 special character</li>