Skip to content

Commit c09b154

Browse files
修复get请求传递嵌套对象或数组时无法正常编码问题
1 parent 7b26cb2 commit c09b154

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"pinia": "^2.0.27",
2929
"print-js": "^1.6.0",
3030
"qrcodejs2-fixes": "^0.0.2",
31+
"qs": "^6.11.0",
3132
"screenfull": "^6.0.2",
3233
"sortablejs": "^1.15.0",
3334
"splitpanes": "^3.1.5",

src/types/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ declare module 'splitpanes';
55
declare module 'js-cookie';
66
declare module '@wangeditor/editor-for-vue';
77
declare module 'js-table2excel';
8+
declare module 'qs';
89

910
// 声明一个模块,防止引入文件时报错
1011
declare module '*.json';

src/utils/request.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
22
import { ElMessage, ElMessageBox } from 'element-plus';
33
import { Session } from '/@/utils/storage';
4+
import qs from 'qs';
45

56
// 配置新建一个 axios 实例
67
const service: AxiosInstance = axios.create({
78
baseURL: import.meta.env.VITE_API_URL,
89
timeout: 50000,
910
headers: { 'Content-Type': 'application/json' },
11+
paramsSerializer: {
12+
serialize: function (params) {
13+
return qs.stringify(params, {allowDots: true});
14+
}
15+
}
1016
});
1117

1218
// 添加请求拦截器

0 commit comments

Comments
 (0)