修复导出含params属性对象参数问题
parent
ede8353503
commit
892065003d
|
@ -23,22 +23,7 @@ service.interceptors.request.use(config => {
|
||||||
}
|
}
|
||||||
// get请求映射params参数
|
// get请求映射params参数
|
||||||
if (config.method === 'get' && config.params) {
|
if (config.method === 'get' && config.params) {
|
||||||
let url = config.url + '?';
|
let url = config.url + '?' + tansParams(config.params);
|
||||||
for (const propName of Object.keys(config.params)) {
|
|
||||||
const value = config.params[propName];
|
|
||||||
var part = encodeURIComponent(propName) + "=";
|
|
||||||
if (value !== null && typeof(value) !== "undefined") {
|
|
||||||
if (typeof value === 'object') {
|
|
||||||
for (const key of Object.keys(value)) {
|
|
||||||
let params = propName + '[' + key + ']';
|
|
||||||
var subPart = encodeURIComponent(params) + "=";
|
|
||||||
url += subPart + encodeURIComponent(value[key]) + "&";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
url += part + encodeURIComponent(value) + "&";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = url.slice(0, -1);
|
url = url.slice(0, -1);
|
||||||
config.params = {};
|
config.params = {};
|
||||||
config.url = url;
|
config.url = url;
|
||||||
|
|
|
@ -179,11 +179,21 @@ export function handleTree(data, id, parentId, children) {
|
||||||
* @param {*} params 参数
|
* @param {*} params 参数
|
||||||
*/
|
*/
|
||||||
export function tansParams(params) {
|
export function tansParams(params) {
|
||||||
let result = ''
|
let result = ''
|
||||||
Object.keys(params).forEach((key) => {
|
for (const propName of Object.keys(params)) {
|
||||||
if (!Object.is(params[key], undefined) && !Object.is(params[key], null) && !Object.is(JSON.stringify(params[key]), '{}')) {
|
const value = params[propName];
|
||||||
result += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) + '&'
|
var part = encodeURIComponent(propName) + "=";
|
||||||
|
if (value !== null && typeof(value) !== "undefined") {
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
for (const key of Object.keys(value)) {
|
||||||
|
let params = propName + '[' + key + ']';
|
||||||
|
var subPart = encodeURIComponent(params) + "=";
|
||||||
|
result += subPart + encodeURIComponent(value[key]) + "&";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result += part + encodeURIComponent(value) + "&";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue