docs: 新增编辑和更新时间
parent
22bcefcb97
commit
9e28effdf5
|
@ -1,3 +1,7 @@
|
|||
---
|
||||
editLink: false
|
||||
---
|
||||
|
||||
# axios-miniprogram
|
||||
|
||||
<p style="display: flex;margin-left:-5px;">
|
||||
|
|
|
@ -10,12 +10,13 @@ export default defineConfig({
|
|||
titleTemplate: ':title - axios',
|
||||
description: '基于 Promise 的 HTTP 请求库,适用于各大小程序平台。',
|
||||
srcDir: 'pages',
|
||||
lastUpdated: true,
|
||||
|
||||
themeConfig: {
|
||||
// https://vitepress.dev/reference/default-theme-config
|
||||
nav: [
|
||||
{ text: '指南', link: '/intro' },
|
||||
{ text: '基础', link: '/basics/options' },
|
||||
{ text: '基础', link: '/basics/request' },
|
||||
],
|
||||
|
||||
sidebar: [
|
||||
|
@ -29,6 +30,7 @@ export default defineConfig({
|
|||
{
|
||||
text: '基础',
|
||||
items: [
|
||||
{ text: '发送请求', link: '/basics/request' },
|
||||
{ text: 'OPTIONS 请求', link: '/basics/options' },
|
||||
{ text: 'GET 请求', link: '/basics/get' },
|
||||
{ text: 'HEAD 请求', link: '/basics/head' },
|
||||
|
@ -150,10 +152,17 @@ export default defineConfig({
|
|||
{ icon: 'github', link: 'https://github.com/zjx0905/axios-miniprogram' },
|
||||
],
|
||||
|
||||
editLink: {
|
||||
pattern:
|
||||
'https://github.com/zjx0905/axios-miniprogram/edit/main/docs/pages/:path',
|
||||
text: '在 GitHub 上编辑此页面',
|
||||
},
|
||||
|
||||
returnToTopLabel: '返回顶部',
|
||||
outlineTitle: '导航栏',
|
||||
darkModeSwitchLabel: '主题',
|
||||
sidebarMenuLabel: '菜单',
|
||||
lastUpdatedText: '最后一次更新',
|
||||
docFooter: {
|
||||
prev: '上一页',
|
||||
next: '下一页',
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
margin-top: var(--vp-nav-height);
|
||||
padding-top: 40px !important;
|
||||
height: calc(100% - var(--vp-nav-height));
|
||||
border-right: 1px solid var(--vp-c-gutter);
|
||||
transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1) !important;
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,6 @@
|
|||
color: var(--vp-c-link);
|
||||
}
|
||||
|
||||
.language-sh,
|
||||
.language-bash,
|
||||
.language-ts {
|
||||
border: 1px solid var(--vp-c-gutter);
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
title: 发送请求
|
||||
---
|
||||
|
||||
# {{ $frontmatter.title }}
|
||||
|
||||
::: tip {{ $frontmatter.title }}
|
||||
发送任意请求方法的 HTTP 请求。
|
||||
:::
|
||||
|
||||
## 基础用法
|
||||
|
||||
您可以直接传入 `url` 发送请求,默认发送的是 `GET` 方法请求。
|
||||
|
||||
```ts
|
||||
import axios from 'axios-miniprogram';
|
||||
|
||||
axios
|
||||
.request('https://api.com/test')
|
||||
.then((response) => {
|
||||
// 成功之后做些什么
|
||||
})
|
||||
.catch((error) => {
|
||||
// 失败之后做些什么
|
||||
});
|
||||
```
|
||||
|
||||
## 携带自定义配置
|
||||
|
||||
您也可以传入第二个参数 `config`,用于指定请求方法以及其他配置项。
|
||||
|
||||
```ts
|
||||
import axios from 'axios-miniprogram';
|
||||
|
||||
axios
|
||||
.request('https://api.com/test', {
|
||||
method: 'POST', // 此时会发送 POST 方法请求
|
||||
data: {
|
||||
name: 'test',
|
||||
password: '123456',
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
// 成功之后做些什么
|
||||
})
|
||||
.catch((error) => {
|
||||
// 失败之后做些什么
|
||||
});
|
||||
```
|
||||
|
||||
## 仅有自定义配置
|
||||
|
||||
您也可以忽略以上示例,直接传入 `config` 发送请求。
|
||||
|
||||
```ts
|
||||
import axios from 'axios-miniprogram';
|
||||
|
||||
axios
|
||||
.request({
|
||||
url: 'https://api.com/test/:id',
|
||||
params: {
|
||||
id: 1,
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
// 成功之后做些什么
|
||||
})
|
||||
.catch((error) => {
|
||||
// 失败之后做些什么
|
||||
});
|
||||
```
|
|
@ -1,3 +1,7 @@
|
|||
---
|
||||
editLink: false
|
||||
---
|
||||
|
||||
# axios-miniprogram
|
||||
|
||||
<p style="display: flex;margin-left:-5px;">
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
---
|
||||
title: 快速上手
|
||||
sidebarDepth: 1
|
||||
lastUpdated: true
|
||||
sitemap:
|
||||
priority: 0.8
|
||||
---
|
||||
|
||||
# 快速上手
|
||||
|
@ -12,16 +8,16 @@ sitemap:
|
|||
|
||||
:::: code-group
|
||||
|
||||
```sh [NPM]
|
||||
npm install -D axios-miniprogram
|
||||
```bash [NPM]
|
||||
$ npm install -D axios-miniprogram
|
||||
```
|
||||
|
||||
```sh [YARN]
|
||||
yarn add -D axios-miniprogram
|
||||
```bash [YARN]
|
||||
$ yarn add -D axios-miniprogram
|
||||
```
|
||||
|
||||
```sh [PNPM]
|
||||
pnpm install -D axios-miniprogram
|
||||
```bash [PNPM]
|
||||
$ pnpm install -D axios-miniprogram
|
||||
```
|
||||
|
||||
::::
|
||||
|
|
Loading…
Reference in New Issue