微信小程序开发(六)第六章APIAPI框架总览(绘图API专列章学习,暂略)网络API媒体API数据API位置API窗口API绘图API开放API设备API第1节网络API1
发送请求:wx
request(object)+数据请求Wx
request({url:url,data:{object},method:get|post,dataType:json,header:{content-type:application/json},success:function(res){vardata=res
data},fail:function(){},complate:function(){}})+选取一个图片上传Wx
chooseImage({Success:function(res){Vartmp=res
tempFilePathsWx
uploadFile({url:url,filePath:tmp[0],name:”file”,formData:{user:test}})}})+下载一段音乐播放Wx
downloadFile({url:url,type:audio,success:function(res){wx
playVoice({filePath:res
tmpFilePath})}})2
上传下载:wx
upload(object)|wx
download(object)3
嵌套字:+连接Wx
connectSocket({url:url,data:{data},header:{},method:get|post})+打开Wx
onSocketOpen(function(res){…})+出错Wx
onSocketError(function(res){…})+发数据Wx
sendSocketMessage({data:msg})+发消息(回调)Wx