全部代码如下,提示回调函数 succeeded is not a function,哪位帮忙看看
login: function login(event) {
var srv = interfaceConfig.interfaceConfig.HOME.login;
var data = {
name: ‘test_st’,
pwd: ‘123456’
};
utils.requestData(srv, data, ‘get’);
utils.requestData(srv, data, ‘get’, succeeded, failed); //调用数据请求函数
function succeeded(res) { //回调函数的定义
console.log(res);
};
function failed(res) { //回调函数的定义
console.log(res);
};
}
//util文件里的代码,请求数据
function requestData(srv, data, method, succeeded, failed) {
var resData = {};
if (data) {
if (method === ‘get’) {
srv += ‘?’;
for (var key in data) {
srv += key + ‘=’ + data[key] + ‘&’;
}
srv = srv.substring(0, srv.length - 1);
} else if (method === ‘post’) {}
}
wx.request({
url: srv, //服务地址
data: data, //数据
header: {
‘content-type’: ‘application/json’
},
method: method,
success: function success(res) {
succeeded(res);
},
fail: function fail(res) {
failed(res);
},
complete: function complete(res) {}
});
}
报错提示截图如下: