前端使用src发起请求,后端返回图片
大部分同学使用img标签的时候,src属性往往都是直接写一个图片的url地址,如 xxx.jpg
img标签的src属性本身是可以发起get请求的,那么我们可以将一个get请求转成字符串给到src属性,然后由img发起请求,后端接收到请求后,返回给我们一张图片。
这样的话,前端 img 标签的 src 属性值看起来就不是一个常见的 .jpg 、.png等格式的图片了,而是类似下面这种:
<img class="css-1safs82" src="https://render.nike.com.cn/is/image/nikeid/?layer=0&src=ir(nikeidrender/af1LowUnlockSP23_v1?obj=/s/g18&color=f7faff&show&obj=/s/g17&color=28282a&show&obj=/s/g19&color=f3f6ff&show&obj=/s/g16&color=a9a6ad&show&obj=/s/g21&color=a5a4ad&show&obj=/s/g1/leather&color=222223&show&obj=/s/g2/leather&color=dcd9d9&show&obj=/s/g3/cord&color=363743&show&obj=/s/g4/leather&color=dcd9d9&show&obj=/s/g5/leather&color=dcd9d9&show&obj=/s/g6/leather&color=d2cdca&show&obj=/s/g7/leather&color=222223&show&obj=/s/g8/leather&color=dcd9d9&show&obj=/s/g20/merry&color=a5a4ad&show&obj=/s/g10&color=141414&show&obj=/s/g15&color=141414&show&obj=/s/g9/small&color=232223&show&obj=/s/g12&color=232223&show&obj=/s/g24/gum&show&obj=/s/g11/slabelb&show&obj=/s/g13/button&show&obj=/s/g14/star&color=f7faff&show&obj=/s/g22/duck&color=f9faff&show&obj=/s/g25&color=1f1f20&show&obj=/s&req=object&fmt=png-alpha&icc=AdobeRGB)bgc=f5f5f5&fmt=jpeg&qlt=90&posN=0,-0.1&icc=AdobeRGB&wid=864" alt="1">
src属性值看起来更像是一个get请求的url。
具体实例:
https://www.nike.com.cn/u/custom-air-force-1-low-unlocked-by-you-10001412/6696950901#Builder
点击你的设计=》专属定制查看效果