js 把 json 转为以 ‘&’ 连接的字符串

/**
 * URL编码;
 * @param {参数} param 
 */
export function toParams(param) {
    var result = ""
    for (let name in param) {
        if (typeof param[name] != 'function') {
            result += "&" + name + "=" + encodeURI(param[name]);
        }
    }
    return result.substring(1)
}

 

posted @ 2018-07-19 17:33  春风得意之时  阅读(2460)  评论(2编辑  收藏  举报