I'm new to Vue and doing some html and css and I want to use a variable as the image directory but the images never load and the variable is being updated by a valid tauri function and I need the images to change as well.
This is some of my code
<template> <img v-bind:src=getimg()> -- and -- <img :src = {{data}}}> -- and -- <img src = {{data}}> -- and much more ... -- </template> <script setup> var data = ref("./assets/4168-376.png") function getimg() { console.log(data1.value) return require(data1.value) } </setup>
According to your code, you are using Vue3 Composition API. There's something missing in your code that might not make your app work properly.
ref
.Extra: When dealing with values that don't require arguments, it's often better to use
computation
. See Vue Computed Properties