Skip to content

Commit ee89104

Browse files
committed
update README.md
1 parent c5a0626 commit ee89104

File tree

2 files changed

+59
-22
lines changed

2 files changed

+59
-22
lines changed

README.md

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
一个用于数字动画过渡的 React 组件库,提供了两种不同的数字动画效果。
44

5+
[![npm version](https://img.shields.io/npm/v/@coderlzw/react-number-animation.svg)](https://www.npmjs.com/package/@coderlzw/react-number-animation)
6+
[![npm downloads](https://img.shields.io/npm/dm/@coderlzw/react-number-animation.svg)](https://www.npmjs.com/package/@coderlzw/react-number-animation)
7+
[![license](https://img.shields.io/npm/l/@coderlzw/react-number-animation.svg)](https://github.com/coderlzw/react-number-animation/blob/main/LICENSE)
8+
9+
## 特性
10+
11+
- 🎯 高性能:使用 React.memo 优化渲染
12+
- 🎨 可定制:支持自定义样式和动画参数
13+
- 📦 轻量级:无额外依赖(除了 motion 库)
14+
- 🎭 平滑动画:使用 easeOutExpo 缓动函数
15+
- 🔢 数字格式化:支持千位分隔和小数点设置
16+
- 📱 响应式:适配各种屏幕尺寸
17+
- 🎨 主题定制:支持自定义样式覆盖
18+
519
## 安装
620

721
```bash
@@ -40,14 +54,32 @@ import { Statistic } from '@coderlzw/react-number-animation';
4054

4155
function App() {
4256
return (
43-
<Statistic
44-
value={1234567.89}
45-
title="总销售额"
46-
prefix="$"
47-
suffix=""
48-
decimals={2}
49-
duration={1500}
50-
/>
57+
<div>
58+
{/* 基础用法 */}
59+
<Statistic
60+
value={1234567.89}
61+
title="总销售额"
62+
prefix="$"
63+
suffix=""
64+
decimals={2}
65+
duration={1500}
66+
/>
67+
68+
{/* 自定义格式化 */}
69+
<Statistic
70+
value={1234567}
71+
title="访问量"
72+
separator=" " // 使用空格作为千位分隔符
73+
suffix=""
74+
/>
75+
76+
{/* 不使用分组 */}
77+
<Statistic
78+
value={123}
79+
useGrouping={false}
80+
title="ID"
81+
/>
82+
</div>
5183
);
5284
}
5385
```
@@ -69,11 +101,17 @@ function App() {
69101
import { AnimatedNumber } from '@coderlzw/react-number-animation';
70102

71103
function App() {
104+
const [value, setValue] = useState(0);
105+
72106
return (
73-
<AnimatedNumber
74-
value={1234}
75-
className="custom-animation"
76-
/>
107+
<div>
108+
<AnimatedNumber
109+
value={value}
110+
className="custom-animation"
111+
/>
112+
<button onClick={() => setValue(v => v + 1)}>增加</button>
113+
<button onClick={() => setValue(v => v - 1)}>减少</button>
114+
</div>
77115
);
78116
}
79117
```
@@ -96,14 +134,6 @@ function App() {
96134
- `.animated-number`: 动画数字容器
97135
- `.digit-container`: 单个数字容器
98136

99-
## 特性
100-
101-
- 🎯 高性能:使用 React.memo 优化渲染
102-
- 🎨 可定制:支持自定义样式和动画参数
103-
- 📦 轻量级:无额外依赖(除了 motion 库)
104-
- 🎭 平滑动画:使用 easeOutExpo 缓动函数
105-
- 🔢 数字格式化:支持千位分隔和小数点设置
106-
107137
## 浏览器支持
108138

109139
- Chrome >= 60
@@ -114,6 +144,9 @@ function App() {
114144
## 开发
115145

116146
```bash
147+
# 克隆仓库
148+
git clone https://github.com/coderlzw/react-number-animation.git
149+
117150
# 安装依赖
118151
npm install
119152

@@ -124,6 +157,10 @@ npm run dev
124157
npm run build
125158
```
126159

160+
## 贡献
161+
162+
欢迎提交 Pull Request 或创建 Issue!
163+
127164
## 许可证
128165

129-
MIT
166+
MIT © [coderlzw](https://github.com/coderlzw)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"repository": {
3131
"type": "git",
32-
"url": "https://github.com/coderlzw/react-number-animation"
32+
"url": "git+https://github.com/coderlzw/react-number-animation.git"
3333
},
3434
"bugs": {
3535
"url": "https://github.com/coderlzw/react-number-animation/issues"

0 commit comments

Comments
 (0)