小程序http模块的用法
小程序通过http封装的模块远程获取服务器API的数据并将请求的结果写入到缓存里
#源码
var that=this;
var array={
url:that.C.service.table,
data:{
skey:that.P.skey,
table:'web_site_description',
map:{
name:'web_site_description'
}
},
method:'GET',
cache:true,
cachedate:'60'
}
that.U.http(array).then(html=>{
that.table.about.default=html.value;
})
#模块组成
* array 传递的参数
* U.http() 函数传递数据
##array参数
参数 | 介绍 | 默认类型 |
---|---|---|
url | api地址 | url参数 |
data | 传递的参数 | 数组 |
method | 请求的类型 | GET/POST |
chace | 是否要缓存 | ture/flase |
cachedate | 缓存的时长 | 分钟 |
###data参数介绍
参数 | 介绍 | 默认类型 |
---|---|---|
skey | 用户加密验证数据 | that.P.skey 调用全局SKEY |
table | 查询的数据库表 | 数据库表 |
map | where |