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