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.
20 lines
419 B
20 lines
419 B
/**
|
|
* 格式化 querystring
|
|
* taskId=3&scene=1011 ->
|
|
* {taskId:3,scene:1011}
|
|
*/
|
|
export const formatQuery = str => {
|
|
if (!str) return;
|
|
const result = {};
|
|
if (str.includes('&')) {
|
|
const arr = str.split('&');
|
|
arr.forEach(item => {
|
|
const arr1 = item.split('=');
|
|
result[arr1[0]] = arr1[1];
|
|
});
|
|
} else {
|
|
const arr = str.split('=');
|
|
result[arr[0]] = arr[1];
|
|
}
|
|
return result;
|
|
};
|
|
|