1、結構代碼
<view class="flex-item preview_img" v-for="(image,index) in feedbackPic" :key="index"> <image :src="getImgUrl(image)" class="img-feed" mode="scaleToFill"> </view>
2、script代碼
<script> export default{ data() { return{ feedbackPic:[], } }, onLoad:function(data){ this.initData(data.appointment_id) }, methods:{ initData:async function(appointment_id){ var that = this; let data = await this.$http.post('/pre/reserve_detail', {'appointment_id':appointment_id}, ).then(function(data){ var feedBack = data.data.feedback_pic; //刪除空白數組 var feedBackImg = feedBack.filter(function (s) { return s && s.trim(); // 注:IE9(不包含IE9)以下的版本沒有trim()方法 }); that.feedbackPic = feedBackImg }).catch(function(data){}); }, getImgUrl(image){ return "http://端口/static/upload/"+image; }, } } </script>