Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

var param = {
        "regionCodes": "110000,120000,13000",
        "purchaseGroups": "A01,A02",
        "feedBackType": "0",
        "isReplied": "0",
        "bTime": "20170301",
        "eTime": "20170431",
        "page": 0,
        "size": 20
    }

原来是post方法直接传参就行,现在先用get方法 所以要把参数拼接在url后面,
类似形式:

https://segmentfault.com/ask?regionCodes=110000,120000,13000&purchaseGroups=A01,A02&feedBackType='0'
...

写了一个函数但是对于不能满足要求(处理不了逗号)

function changeParam(param){
        return JSON.stringify(param).replace(/:/g,'=').replace(/,/g,'&').replace(/{/g,'?').replace(/}/g,'').replace(/"/g,'');
    }
求一个函数完美转换的函数

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
421 views
Welcome To Ask or Share your Answers For Others

1 Answer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...