This commit is contained in:
huhao
2026-08-20 17:53:59 +08:00
parent f1b537d738
commit b32cda3e85
5 changed files with 139 additions and 76 deletions
+3 -4
View File
@@ -95,12 +95,11 @@ export function request(url, options = {}) {
* 兼容两种调用方式:
* get('/path?key=val') 旧风格(URL 自带参数)
* get('/path', { key: 'val' }) 新风格(参数对象,自动编码)
* 不可对形参 url 做 += 重赋值,正式版 Babel 会把形参编译为只读,触发 "a" is read-only
*/
export const get = (url, params) => {
if (params) {
url += toQueryString(params)
}
return request(url, { method: 'GET' })
const fullUrl = params ? `${url}${toQueryString(params)}` : url
return request(fullUrl, { method: 'GET' })
}
/**