vue图片src动态拼接
<img :src="getImgUrl(item)" v-for="(item,index) of imgList" :key="index" />
<script>
const imgList=[1,2,3,4,5,6,7,8]
data(){
return{
imgList,
}
}
getImgUrl(i){
return require("../../assets/tourpic/picture"+i+".jpg")
}
</script>
或者
<img :src="require('../../assets/tourpic/picture'+item+'.jpg')" v-for="(item,index) of imgList" :key="index" />
<script>
const imgList=[1,2,3,4,5,6,7,8]
data(){
return{
imgList,
}
}
</script>