feige996 hace 1 año
padre
commit
ff01cc70c0
Se han modificado 1 ficheros con 26 adiciones y 0 borrados
  1. 26 0
      docs/base/8-request.md

+ 26 - 0
docs/base/8-request.md

@@ -75,6 +75,32 @@ export const getFooAPI2 = (name: string) => {
 
 依然非常简洁,深受妹子喜爱。
 
+> 完成范例如下
+
+```ts
+/** GET 请求 */
+export const getFooAPI = (name: string) => {
+  return http.get<IFooItem>('/foo', { name })
+}
+/** GET 请求;支持 传递 header 的范例 */
+export const getFooAPI2 = (name: string) => {
+  return http.get<IFooItem>('/foo', { name }, { 'Content-Type-100': '100' })
+}
+
+/** POST 请求 */
+export const postFooAPI = (name: string) => {
+  return http.post<IFooItem>('/foo', { name })
+}
+/** POST 请求;需要传递 query 参数的范例;微信小程序经常有同时需要query参数和body参数的场景 */
+export const postFooAPI2 = (name: string) => {
+  return http.post<IFooItem>('/foo', { name })
+}
+/** POST 请求;支持 传递 header 的范例 */
+export const postFooAPI3 = (name: string) => {
+  return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type-100': '100' })
+}
+```
+
 ## 图片上传
 
 `template` 部分编码如下: