请问image标签中src怎么加请求的header
发布于 5 年前 作者 yong84 9132 次浏览 来自 问答

例如服务端在接收图片请求时,需要获得请求header中的数据,请问在image标签中如何请求

<image src=“https://my.server.com?getpic=photo1” />

正常请求:

wx.request({
url: "https://my.server.com?getpic=photo1",
header:{
    "Content-Type": "application/json;charset=utf-8",
    "myAuth" : "1234abc"
},
success: function(e){
    console.log("image ", e, tmpInfo.key)

},
})

5 回复

在使用图片前,先wx.downloadFile图片(此时可以带header),下载成功后用tempFilePath去改变图片的src值

downloadFile把图下下来?

get请求,是可以传参数的,你对http协议理解就仅限于在header里存参数吗

图文请求展示加header是为了什么啊,还要限制图片展示吗?图片加水印能解决你的问题吗。

加不了的老哥,src只能是资源的实际地址,如:http://www.test.com/dd.png,request请求才可以加,

回到顶部