docs: 新增编辑和更新时间
parent
22bcefcb97
commit
9e28effdf5
|
@ -1,3 +1,7 @@
|
||||||
|
---
|
||||||
|
editLink: false
|
||||||
|
---
|
||||||
|
|
||||||
# axios-miniprogram
|
# axios-miniprogram
|
||||||
|
|
||||||
<p style="display: flex;margin-left:-5px;">
|
<p style="display: flex;margin-left:-5px;">
|
||||||
|
|
|
@ -10,12 +10,13 @@ export default defineConfig({
|
||||||
titleTemplate: ':title - axios',
|
titleTemplate: ':title - axios',
|
||||||
description: '基于 Promise 的 HTTP 请求库,适用于各大小程序平台。',
|
description: '基于 Promise 的 HTTP 请求库,适用于各大小程序平台。',
|
||||||
srcDir: 'pages',
|
srcDir: 'pages',
|
||||||
|
lastUpdated: true,
|
||||||
|
|
||||||
themeConfig: {
|
themeConfig: {
|
||||||
// https://vitepress.dev/reference/default-theme-config
|
// https://vitepress.dev/reference/default-theme-config
|
||||||
nav: [
|
nav: [
|
||||||
{ text: '指南', link: '/intro' },
|
{ text: '指南', link: '/intro' },
|
||||||
{ text: '基础', link: '/basics/options' },
|
{ text: '基础', link: '/basics/request' },
|
||||||
],
|
],
|
||||||
|
|
||||||
sidebar: [
|
sidebar: [
|
||||||
|
@ -29,6 +30,7 @@ export default defineConfig({
|
||||||
{
|
{
|
||||||
text: '基础',
|
text: '基础',
|
||||||
items: [
|
items: [
|
||||||
|
{ text: '发送请求', link: '/basics/request' },
|
||||||
{ text: 'OPTIONS 请求', link: '/basics/options' },
|
{ text: 'OPTIONS 请求', link: '/basics/options' },
|
||||||
{ text: 'GET 请求', link: '/basics/get' },
|
{ text: 'GET 请求', link: '/basics/get' },
|
||||||
{ text: 'HEAD 请求', link: '/basics/head' },
|
{ text: 'HEAD 请求', link: '/basics/head' },
|
||||||
|
@ -150,10 +152,17 @@ export default defineConfig({
|
||||||
{ icon: 'github', link: 'https://github.com/zjx0905/axios-miniprogram' },
|
{ 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: '返回顶部',
|
returnToTopLabel: '返回顶部',
|
||||||
outlineTitle: '导航栏',
|
outlineTitle: '导航栏',
|
||||||
darkModeSwitchLabel: '主题',
|
darkModeSwitchLabel: '主题',
|
||||||
sidebarMenuLabel: '菜单',
|
sidebarMenuLabel: '菜单',
|
||||||
|
lastUpdatedText: '最后一次更新',
|
||||||
docFooter: {
|
docFooter: {
|
||||||
prev: '上一页',
|
prev: '上一页',
|
||||||
next: '下一页',
|
next: '下一页',
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
margin-top: var(--vp-nav-height);
|
margin-top: var(--vp-nav-height);
|
||||||
padding-top: 40px !important;
|
padding-top: 40px !important;
|
||||||
height: calc(100% - var(--vp-nav-height));
|
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;
|
transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +107,6 @@
|
||||||
color: var(--vp-c-link);
|
color: var(--vp-c-link);
|
||||||
}
|
}
|
||||||
|
|
||||||
.language-sh,
|
|
||||||
.language-bash,
|
.language-bash,
|
||||||
.language-ts {
|
.language-ts {
|
||||||
border: 1px solid var(--vp-c-gutter);
|
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
|
# axios-miniprogram
|
||||||
|
|
||||||
<p style="display: flex;margin-left:-5px;">
|
<p style="display: flex;margin-left:-5px;">
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
---
|
---
|
||||||
title: 快速上手
|
title: 快速上手
|
||||||
sidebarDepth: 1
|
|
||||||
lastUpdated: true
|
|
||||||
sitemap:
|
|
||||||
priority: 0.8
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# 快速上手
|
# 快速上手
|
||||||
|
@ -12,16 +8,16 @@ sitemap:
|
||||||
|
|
||||||
:::: code-group
|
:::: code-group
|
||||||
|
|
||||||
```sh [NPM]
|
```bash [NPM]
|
||||||
npm install -D axios-miniprogram
|
$ npm install -D axios-miniprogram
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh [YARN]
|
```bash [YARN]
|
||||||
yarn add -D axios-miniprogram
|
$ yarn add -D axios-miniprogram
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh [PNPM]
|
```bash [PNPM]
|
||||||
pnpm install -D axios-miniprogram
|
$ pnpm install -D axios-miniprogram
|
||||||
```
|
```
|
||||||
|
|
||||||
::::
|
::::
|
||||||
|
|
Loading…
Reference in New Issue