(1)<img src="../assets/img/favicon.ico">
(2)
v-for="u in list"
<img class="pic" :src="require('../assets/'+u.avatar)">
(3)示例1:(图片排列比较整齐时)
this.$http.get("http://localhost/wyyx/indexProList.php",{emulateJSON:true,withCredential:true}).then((response)=>{
this.pList1=response.body;
})
<div>
<img v-for="p in pList1" :src="require('../assets/'+p.img_path)">
</div>
(4)示例2:(图片排列不整齐且图片比较时)
this.$http.get("http://localhost/wyyx/indexProduct.php",{emulateJSON:true,withCredentials:true}).then((response)=>{
this.path1=require('../assets/'+response.body[0][1]);
this.path2=require('../assets/'+response.body[1][1]);
this.path3=require('../assets/'+response.body[2][1]);
this.path4=require('../assets/'+response.body[3][1]);
})
<div>
<img :src="path1" alt="">
</div>
<div>
<img :src="path2" alt="">
</div>
<div>
<img :src="path3" alt="">
<img :src="path4" alt="">
</div>
这里我本来是用pList[0]、pList[1]....,结果发现vue不认账呀,所以就使用了四个变量
还有,最最重要的一点是,当非常肯定自己的代码正确却发现效果不对时,请重启服务器,vue服务器有时不稳定哦!!!!!
补:
发现有时在html上加require会报错,当报错时可以在js中先require后再放入html中