NSString *strFilePath = [self.viewController.commandDelegate pathForResource:[urlNosmoke path]]
NSURL *urlNonSmoking = [NSURL URLWithString:@"?nonSmokingId=2013" relativeToURL:[NSURL URLWithString:strFilePath]]
NSURLRequest *req = [[NSURLRequest alloc] initWithURL:urlNonSmoking
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:20.0f]
[self.viewController.webViewEngine loadRequest:req]
在Url尾部用 get 方法添加参数格式如下:
url?变量1=参数1,变量2=参数2…
url是原先的不变,然后接一个问号,接着是所有的键值对,用逗号分隔
parseParam(param, key, encode){
if(param==null) return ''
var paramStr = ''
var t = typeof (param)
if (t == 'string' || t == 'number' || t == 'boolean') {
paramStr += '&' + key + '=' + ((encode==null||encode) ? encodeURIComponent(param) : param)
} else {
for (var i in param) {
var k = key == null ? i : key + (param instanceof Array ? '[' + i + ']' : '.' + i)
paramStr += parseParam(param[i], k, encode)
}
}
return paramStr
}
调用parseParam(obj)
console.log(parseParam(obj))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)