我有一个API,我正尝试通过以下方法传递参数:
Test: function (Product, Code, success, error, context) {
return API.http.get(API.methods.path + 'Test' {
Product: product,
Code:code //this is the problem that comes in.
}, success, error, context);
},
因此代码返回了一个数字,我需要将其作为字符串传递给波纹管函数:
public class Test : Query
{
public string product { get; set; }
public IEnumerable<string> code { get; set; } = new List<string>();
}
但是 product 可以通过,但是 代码 不能通过,因为它不是字符串。< / p>
这就是我尝试过的:
Test: function (Product, Code, success, error, context) {
var codestring = '';
(Code || []).forEach(g => {
if (codestring.length === 0)
codestring += '?code=' + Number(g);
else
codestring += '&code=' + Number(g);
});
return API.http.get(API.methods.path + 'Test' + codestring, {
Product: product
}, success, error, context);
},
现在,上面的代码最终传递了 code ,但是现在没有传递 Product ,而是将其传递为null。 我究竟做错了什么?如何将代码作为字符串传递?