# @crossfox/react-animated-number 中文文档

规范地址：https://npmcn.com/package/%40crossfox/react-animated-number/

版本：1\.0\.18
npm 元数据更新时间：2023-10-10T12:33:22.781Z
中文译文更新时间：2026-11-11T01:35:55.796Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40crossfox/react-animated-number
原文对照：https://npmcn.com/package/%40crossfox/react-animated-number/?lang=original
项目主页：https://crossfox.online/
源码仓库：https://github.com/OleksiiFursov/crossfox-front#master/package/react/animated-number

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：67.3 kB，9 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react ^16\.8\.0 \|\| ^17\.0\.0 \|\| ^18\.0\.0
- 首次发布：2023-09-19T14:12:54.048Z
- 最新版本发布：2023-10-10T12:33:22.572Z
- 近 30 天下载量：5098（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：18（近 12 个月 0 个）

## 中文简介

一个轻量级的JavaScript组件,旨在在不同状态或值之间创建平滑和有视觉吸引力的动画转换,增强用户在网络应用方面的经验.

## 安装

```sh
npm install @crossfox/react-animated-number
```

也可以使用：`pnpm add @crossfox/react-animated-number`、`yarn add @crossfox/react-animated-number`、`bun add @crossfox/react-animated-number`

## README

# CrossFox 的回放动画数字

[![npm version](https://badge.fury.io/js/@crossfox%2Freact-animated-number.svg)](https://www.npmjs.com/package/@crossfox/react-animated-number) [![Blazing Fast](https://badgen.now.sh/badge/speed/blazing%20%F0%9F%94%A5/green)](https://npmcn.com/package/%40crossfox/react-animated-number/@crossfox/react-animated-number) [![gzip size](http://img.badgesize.io/https://unpkg.com/@crossfox/react-animated-number/dist/index.js?compression=gzip)](https://unpkg.com/@crossfox/react-animated-number/dist/index.js) [![NPM downloads](https://img.shields.io/npm/dm/@crossfox/react-animated-number.svg?style=flat-square)](https://npmjs.org/package/@crossfox/react-animated-number) ![license](https://badgen.now.sh/badge/license/Apache-2.0)

一个轻而易举的快活反应组件,易于使用,并与16.8和更高等反应相配合.

-   <1kb小型图书馆
-   方便使用
-   \* 业绩好
-   无依赖性

### 发音:

[在此查看演示](https://oleksiifursov.github.io/crossfox-front/build/#/component-animated-number)

### 安装

```bash
npm install @crossfox/react-animated-number
```

```bash
yarn add @crossfox/react-animated-number
```

### 作者

-   奥列克西·富尔索夫 [@nodePro777 请检查url=值 (帮助)](https://t.me/nodePro777)

### 道具

| 名称 | 类型 | 默认值 | 说明 | 版本 |
| --- | --- | --- | --- | --- |
| `value` | `number` | `0` | 当前值, 变化时触发动画 | 1.00 (中文(简体) ) |
| `round` | `number` | `0` | 小数位数 | 1.00 (中文(简体) ) |
| `duration` | `number` | `1000` | 动画持续时间(分) | 1.00 (中文(简体) ) |
| `className` | `string` | `0` | 您可以添加自定义类 | 1.00 (中文(简体) ) |
| `showArrow` | `boolean` | `false` | 显示显示增长或下降的数字左边的箭头 | 1.00 (中文(简体) ) |
| `reserveMinusSpace` | `boolean` | `false` | 添加减号的空格 | 1.00 (中文(简体) ) |
| `reserve` | `number` | `0` | 为数字预留空间 | 1.00 (中文(简体) ) |
| `align` | `string` | `"left"` | 预定方向。 仅作为"左"使用,其他情况下为"右" | 1.00 (中文(简体) ) |
| `prefix` | `string` | `""` | 添加要放在数字前面的文本。 例如,"100美元" | 1.00 (中文(简体) ) |
| `suffix` | `string` | `""` | 添加要放在数字后的案文。 例如"1000 UAH" | 1.00 (中文(简体) ) |
| `rate` | `string` | `60` | 每秒更新次数 | 1.00 (中文(简体) ) |
| `tagName` | `string` | `div` | 要为数字创建标记 . | 1.00 (中文(简体) ) |
| `onFinish` | `function` | 函数( e)  
旧的瓦卢,  
数值,  
尔  
(中文(简体) ) | 动画完成后事件触发. 返回旧数字、当前数字和元素节点. | 1.00 (中文(简体) ) |

### 类名状态

| 类Name | 说明 |
| --- | --- |
| `is-progress` | 在动画中添加 |
| `is-increment` | 通知人数增加 |
| `is-decrement` | 通知人数已减少 |

## 示例

```jsx
import React, { useState } from 'react';
import AnimatedNumber from '@crossfox/react-animated-number';

const App = () => {
    const [value, setValue] = useState(0)
    const onClickRandom = () => setValue(Math.random() * 10000 >> 0)
    return (<>
        <button onClick={onClickRandom}>Random value</button>
        <AnimatedNumber value={value}/>
    </>)
}
```

## 常见问题

### @crossfox/react-animated-number 是什么？

一个轻量级的JavaScript组件,旨在在不同状态或值之间创建平滑和有视觉吸引力的动画转换,增强用户在网络应用方面的经验\.

### 如何安装 @crossfox/react-animated-number？

在项目目录运行 npm install @crossfox/react-animated-number，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（^16\.8\.0 \|\| ^17\.0\.0 \|\| ^18\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @crossfox/react-animated-number 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @crossfox/react-animated-number 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @crossfox/react-animated-number 可以商用吗？

@crossfox/react-animated-number 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @crossfox/react-animated-number 的下载量有多少？

根据 npm 官方下载统计，@crossfox/react-animated-number 在 2026/10/11 – 2026/11/09 这 30 天内被下载 5,098 次，日均约 170 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @crossfox/react-animated-number 还在维护吗？

最新版本 1\.0\.18 发布于 2023/10/10（3 年前）；至今共发布 18 个版本，其中过去 12 个月发布了 0 个；首次发布于 2023/09/19。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

