- If you don't want to change the path, you can use require to load the image as a module
- Using require is to import the picture as a module first, and then bind it.
<!--静态-->
<v-img :src="require('../../assets/img/classic.jpg')" alt="picture"/>
<!--动态-->
<v-img :src="require('@/assets/img/'+testUrl+'.png')"/>
- When you need to implement dynamic loading of pictures, you need to pass a variable to require, and assign a value to this variable in the method
<template>
<v-card class="my-auto mx-0" flat tile>
<v-img :src="require('@/assets/img/'+testUrl+'.png')"/>
</v-card>
</template>
<script>
export default {
name: "assessmentResults",
data() {
return {
testUrl:"1img",//测评图片路径
}
},
methods: {
ingUrl(){
//...
this.testUrl="222img";
},
},
}
</script>
Reference document: src dynamic assignment of img in vue (path of local image) - Short Book