美文网首页
Dom/WXML中直接请求接口显示图片

Dom/WXML中直接请求接口显示图片

作者: Henry01 | 来源:发表于2021-07-12 10:57 被阅读0次

scr中为完整的接口请求地址,ip为动态从公共中获取,timedSnapShoot/showImg为接口地址,id为入参字段,shootId为所需的id,在后端不直接返回可以预览地址时,此写法可以将图片直接显示到页面中。

1,vue项目中使用:
HTML:

<el-image :src="IP + 'timedSnapShoot/showImg/'+ shootId +'?id=' + shootId" lazy></el-image>

JS:

 data() {
    return {
          IP:'192.168.2.118::8080',
          shootId:10,
    }
  }

2,微信小程序中:
WXML:

 <image class="image_frame"  src="{{IP + item.shootId + '?id' +  item.shootId}}" mode="widthFix"></image> 

JS:

Page({
  data: {
         IP:'http://192.168.2.102:4329/timedSnapShoot/showImg/',
          shootId:1,
    }
  })

相关文章

网友评论

      本文标题:Dom/WXML中直接请求接口显示图片

      本文链接:https://www.haomeiwen.com/subject/ahhaultx.html