Based on your code, you are using Vue3 Composition API. There are a few things that are missing from your code that probably didn't made your app work.
- As others have mention, you don't use curly braces in the attributes. You use
<img :src="variable"> // just use : in front of an attribute and it will consider as v-bind
<img v-bind:src="variable"> // or you directly use v-bind, less commonly used
<img :src="'static string'"> // no point doing this, but just a reference of how it works
- When you are using composition API, you will have to import the functions first such as
ref.
<template>
<img :src="data">
<img v-bind:src="data">
<img :src="getimg()">
</template>
<script setup>
import { ref } from 'vue'
const data = ref("./assets/4168-376.png") // prefer const over var cus this variable will never be reassigned
function getimg() {
// why are you using data1.value tho? It should be data.value
// also i don't think 'require' is needed here
return require(data1.value) // i just copy paste from your code
}
</script>
Extra: when dealing with values that does not require a parameter, usually using computed will be better. Refer Vue computed properties
<template>
<img :src="data">
<img v-bind:src="data">
<img :src="getImg">
</template>
<script setup>
import { ref, computed } from 'vue' // import it first
const data = ref("./assets/4168-376.png")
const getImg = computed(() => {
return data.value
})