Skip to content

Commit bc5b77f

Browse files
author
AxT-Team Bot
committed
docs: add browser cdn guidance
1 parent cc615e7 commit bc5b77f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,39 @@ const result = await client.social.getSocialQqUserinfo({ qq: '10001' })
2323
console.log(result)
2424
```
2525

26+
## CDN 引入
27+
28+
`uapi-browser-sdk` 已发布到 npm,因此任意支持 npm 包的 CDN 都可以直接加载,无需构建步骤。推荐做法是按照下面的示例引用,并在生产环境中固定版本号(`@latest` 适合快速试用)。
29+
30+
### jsDelivr(官方推荐)
31+
32+
```html
33+
<script type="module">
34+
import { UapiClient } from 'https://cdn.jsdelivr.net/npm/uapi-browser-sdk@latest/dist/index.js';
35+
36+
const client = new UapiClient('https://uapis.cn/api/v1');
37+
const data = await client.network.getNetworkMyip();
38+
console.log(data);
39+
</script>
40+
```
41+
42+
### UNPKG(原生 ESM)
43+
44+
```html
45+
<script type="module">
46+
import { UapiClient } from 'https://unpkg.com/uapi-browser-sdk@latest/dist/index.js?module';
47+
// ...
48+
</script>
49+
```
50+
51+
### ESM CDN(esm.run / esm.sh 等)
52+
53+
```ts
54+
import { UapiClient } from 'https://esm.run/uapi-browser-sdk@latest';
55+
```
56+
57+
以上三种方式都会返回同一份浏览器原生 ESM 模块,因此可以根据团队的缓存策略或地理覆盖选择最合适的 CDN。
58+
2659
## 特性
2760

2861
现在你不再需要反反复复的查阅文档了。

0 commit comments

Comments
 (0)