feat: 修改 项目说明示例代码

This commit is contained in:
zhangxiangliang 2020-07-29 09:19:48 +08:00
parent d52fa41742
commit a0663455f4

View File

@ -7,7 +7,7 @@
## 股票数据 ## 股票数据
| 名称 | 接口名 | 官网 | | 名称 | 接口名 | 官网 |
| --- | --- | --- | | -------- | ------- | -------------------------------------- |
| 基础示例 | base | 无 | | 基础示例 | base | 无 |
| 网易财经 | netease | [传送门](https://money.163.com/) | | 网易财经 | netease | [传送门](https://money.163.com/) |
| 新浪股票 | sina | [传送门](https://finance.sina.com.cn/) | | 新浪股票 | sina | [传送门](https://finance.sina.com.cn/) |
@ -24,10 +24,11 @@ yarn install stock-api
### 获取股票实时数据 ### 获取股票实时数据
```typescript ```typescript
import { api } from 'stock-api/stocks/netease'; import { api } from "stock-api/stocks";
// 省略 async 相关内容 // 省略 async 相关内容
const stock = await (new api).getStock('SH510500'); const stock = await(new api["sina"]()).getStock("SH510500");
const stock = await(new api["netease"]()).getStock("SH510500");
// 结果: // 结果:
// { code: 'SH510500', name: '500ETF', price: 7.253, percent: -0.001102 } // { code: 'SH510500', name: '500ETF', price: 7.253, percent: -0.001102 }
@ -36,10 +37,11 @@ const stock = await (new api).getStock('SH510500');
### 获取股票组实时数据 ### 获取股票组实时数据
```typescript ```typescript
import { api } from 'stock-api/stocks/netease'; import { api } from "stock-api/stocks";
// 省略 async 相关内容 // 省略 async 相关内容
const stock = await (new api).getStocks(['SH510500']); const stock = await(new api["sina"]()).getStocks(["SH510500"]);
const stock = await(new api["netease"]()).getStocks(["SH510500"]);
// 结果: // 结果:
// [{ code: 'SH510500', name: '500ETF', price: 7.253, percent: -0.001102 }] // [{ code: 'SH510500', name: '500ETF', price: 7.253, percent: -0.001102 }]
@ -49,6 +51,6 @@ const stock = await (new api).getStocks(['SH510500']);
> 韭菜小猪也有暴富梦~ > 韭菜小猪也有暴富梦~
* 在困惑的城市里总少不了并肩同行的 伙伴 让我们一起成长。 - 在困惑的城市里总少不了并肩同行的 伙伴 让我们一起成长。
* 如果您想让更多人看到文章可以点个 点赞。 - 如果您想让更多人看到文章可以点个 点赞。
* 如果您想激励小二可以到 Github 给个 小星星。 - 如果您想激励小二可以到 Github 给个 小星星。