You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
408 B
19 lines
408 B
/**
|
|
* 拼接url地址
|
|
*
|
|
* @param href
|
|
* @param opts
|
|
* @returns {*}
|
|
*/
|
|
export default function (href, opts){
|
|
if(!opts){
|
|
return href;
|
|
}
|
|
let params = '',
|
|
keys = Object.keys(opts).map(function(key){
|
|
return encodeURIComponent(key) + '=' + encodeURIComponent(opts[key]);
|
|
}),
|
|
div = href.indexOf('?') != -1 ? '&' : '?';
|
|
params = keys.join('&');
|
|
return href + div + params;
|
|
}
|
|
|