1.

微信小程序调用API,首先你带有一个api,推荐聚合数据,百度一下,认证注册一下,会获得一个API,还有appkey。

2.

话不多说,在默认的index.js里写

3.

onLoad:function(options){

4.

wx.request({

5.

url:'http://v.juhe.cn/toutiao/index',//API比如我调用了聚合头条api,这个是免费的

6.

data:{

7.

key:'你自己获得到的appkey'

8.

},

9.

header:{

10.

'content-type':'application/json',//默认值

11.

},

12.

success:(res){

13.

console.log(res)

14.

},

15.

fail:(err){

16.

console.log(err)

17.

}

18.

})

19.

/*wx.showLoading({

20.

title:'加载中',

21.

})

22.

//this.text();

23.

*/

24.

},

TAG标签: 微信小程序调用API简单案例微信小程序api接口调用微信小程序ibeacon

http://www.xiaochengxub.com/read-96267.html