I'm generating a template literal html that feeds into the v-tooltip. I'm trying to bind the src of the images inside each li to react to changes in other computed properties but it doesn't seem to work. Is it even possible to v-bind an attribute inside a template literal?
I have the following template:
<template>
<div v-tooltip="passwordAssistant">
</div>
</template>
and the following properties-
props: {
modelValue: {
type: String,
default: '',
},
computed: {
passwordAssistant() {
return `<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>`
},
iconDeterminator(value) {
return value ? require('@/assets/images/v-icon.svg') : require('@/assets/images/x-icon.svg');
},
contains_eight_characters() {
console.log(this.modalValue.length);
return this.iconDeterminator(this.modelValue.length >= 8);
},
--- PART 1: v-tooltip ----
According to the vuetify documention on v-toolip
This is how to correctly use v-tooltip;
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);
Variables (sorry I will be using Vue 3 syntax here I don't know if you're using Vue 2 or 3);
Binding the imageSources to the computed properties;