企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 发起请求 >>一般在监听页面加载的生命周期中发起请求 ``` //定义个局部的this let _this = this; wx.request({ url: 'http://localhost:8888/',// 接口地址 data:{}, header: {},// 设置请求头 method: 'GET',// 请求方式,GET POST PUT DELETE PATCH dataType: 'json',//返回的数据格式有json,jsonp responseType: 'text',//响应的数据为文本 //请求成功的回调 success: function(res) { //一般在这里设置数据 }, //失败的时候回调 fail: function(res) { console.log(res) }, //接口调用结束的回调函数(调用成功、失败都会执行) complete: function(res) { //console.log(res) }, }) ```