vue3-request 1.0.19 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
## ⚡ 快速安装
|
|
2
|
+
|
|
3
|
+
```bash [pnpm]
|
|
4
|
+
pnpm add vue3-request
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## 🚀 5 分钟上手
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<template>
|
|
11
|
+
<div>
|
|
12
|
+
<div v-if="loading">加载中...</div>
|
|
13
|
+
<div v-else-if="error">{{ error.message }}</div>
|
|
14
|
+
<div v-else>{{ data }}</div>
|
|
15
|
+
<button @click="refresh">刷新</button>
|
|
16
|
+
<button @click="abort">中止</button>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import { useRequest } from "vue3-request";
|
|
22
|
+
|
|
23
|
+
const getUserInfo = async () => {
|
|
24
|
+
const response = await fetch("/api/userInfo", {
|
|
25
|
+
signal: signal.value,
|
|
26
|
+
});
|
|
27
|
+
return response.json();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// 一行代码搞定状态管理
|
|
31
|
+
const { data, error, loading, signal, refresh, abort } =
|
|
32
|
+
useRequest(getUserInfo);
|
|
33
|
+
</script>
|
|
34
|
+
```
|
package/package.json
CHANGED