uni-app后台數據拿到的圖片路徑配上域名


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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM