Skip to content

Commit

Permalink
docs: 📝 Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Dec 26, 2023
1 parent 6b6b344 commit b578267
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 4 deletions.
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,73 @@ app.config.globalProperties.$assets = useAssets
<!-- 更多使用方式请参阅 https://tailwindcss.com/docs -->
```

#### 请求后端数据

> 详细使用请参阅 [uni-network](https://github.com/uni-helper/uni-network)
```js
import request from '@/utils/request/index.js'

// GET
request.get(
'/mock',
{ id: 'mock-id' },
{
/* more-options */
}
)

// POST
request.post(
'/mock',
{ id: 'mock-id' },
{
/* more-options */
}
)

// Upload
request.upload({
url: '/mock',
dataType: 'json',
headers: {
'content-type': 'multipart/form-data',
},
})

// Common
request({
method: 'post',
url: '/mock',
data: {
id: 'mock-id',
},
headers: {
'content-type': 'application/json',
},
})

// 扩展方法

// 继承于 request.post,请求头默认添加 'Content-Type': 'multipart/form-data'
request.form(
'/mock',
{ id: 'mock-id' },
{
/* more-options */
}
)

// 继承于 request.post,请求头默认添加 'Content-Type': 'application/x-www-form-urlencoded'
request.query(
'/mock',
{ id: 'mock-id' },
{
/* more-options */
}
)
```

#### 路由间功能跳转

```js
Expand Down
5 changes: 1 addition & 4 deletions src/utils/request/uni-network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ export default ({
})

service.interceptors.request.use(service.onRequest, service.onRequestError)
service.interceptors.response.use(
service.onResponse,
service.onResponseError,
)
service.interceptors.response.use(service.onResponse, service.onResponseError)

/**
* 以表单形式提交数据
Expand Down

0 comments on commit b578267

Please sign in to comment.