# vue-number-counter

> A Vue.js project, (基于vue2的数字滚动（翻牌）插件)

Latest version **1.0.5** (published 2018-09-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-number-counter
pnpm add vue-number-counter
yarn add vue-number-counter
bun add vue-number-counter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2018-09-05 |
| First published | 2018-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6.0.0 |
| Dependencies | 0 |
| Unpacked size | 29.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | lijunqi |
| Maintainers | hz-ljq |
| Keywords | vue2, counter, number, character, vue-counter, vue counter, number-counter, number counter, number-animate, number animate, number-animation, number animation, character-counter, character counter, character-animate, character animate, character-animation, character animation, vue-number, vue number, vue-number-counter, vue number counter, vue-character, vue character, vue-character-counter, vue character counter, numbers, characters, numbers-counter, numbers counter, numbers-animate, numbers animate, numbers-animation, numbers animation, characters-counter, characters counter, characters-animate, characters animate, characters-animation, characters animation, vue-numbers, vue numbers, vue-numbers-counter, vue numbers counter, vue-characters, vue characters, vue-characters-counter, vue characters counter |

## Links

- npm: https://www.npmjs.com/package/vue-number-counter
- Repository: https://github.com/hz-ljq/vue-number-counter
- Homepage: https://github.com/hz-ljq/vue-number-counter#readme
- Issues: https://github.com/hz-ljq/vue-number-counter/issues
- npm.io page: https://npm.io/package/vue-number-counter

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2018-09-05
- 1.0.4 — 2018-08-30
- 1.0.3 — 2018-08-30
- 1.0.2 — 2018-08-30
- 1.0.1 — 2018-08-30
- 1.0.0 — 2018-08-30

## README

# vue-number-counter

> 基于vue2的数字滚动（翻牌）插件
```
特点1：传给插件的value类型，支持String和Number类型；
特点2：当传给插件的value是Number类型时，支持千位分隔符格式（用于金额、标价等），支持自定义小数位数；
特点3：支持自定义字符表，支持每个字符在激活状态下的样式控制；
```

### Demo演示:
![avatar](https://github.com/hz-ljq/vue-number-counter/blob/master/src/assets/images/demo.gif)

### NPM
```
npm install vue-number-counter --save
```

### Mount
- mount with global
```js
import Vue from 'vue'
// require styles
import 'vue-number-counter/dist/vue-number-counter.css'
import VueNumberCounter from 'vue-number-counter'
Vue.use(VueNumberCounter)
```

- mount with component
```js
// require styles
import 'vue-number-counter/dist/vue-number-counter.css'
import { VueNumberCounter } from 'vue-number-counter'
export default {
  components: {
    VueNumberCounter
  }
}
```

### Usage
```js
<div class='my-wrapper'>
  <div class='my-title'>My Number: </div>

  <vue-number-counter class='my-number' :value="17842.7129" :option='myOption' />

</div>
```

### Demo参考:
<https://github.com/hz-ljq/vue-number-counter/blob/master/src/components/Demo.vue>

### Props
| Name | Type | Default | Description |
| ------ | ------ | ------ | ------ |
| :value | String/Number | "0" | <font size=2>要进行动画效果的数字或者字符串 |
| :option | Object | duration: 2000,<br/>characterWidth: 16,<br/>addCharacter: [],<br/>replaceCharacterMap: [],<br/>decimals: 2,<br/>thousandsSeparatorFlag: false | <font size=2>配置项 |

### :option（Detail explanation）
| Name | Type | Default | Description |
| ------ | ------ | ------ | ------ |
| duration | Number | <font size=1>2000（单位：ms） | <font size=1>字符或数字滚动的动画过渡时间； |
| characterWidth | Number | <font size=1>16（单位：px）| <font size=1>每个字符所占的宽度； |
| addCharacter | Array | <font size=1>[] | <font size=1>向默认的字符表里追加新的字符，必须是单字符数组，比如：['♪', '∮']； |
| replaceCharacterMap | Array | <font size=1>[] | <font size=1>替换默认的字符表；|
| decimals | Number | <font size=1>2 | <font size=1>四舍五入小数位数（只在:value参数是Number类型时，才有效）；|
| thousandsSeparatorFlag | Boolean | <font size=1>false | <font size=1>是否需要添加千位分隔符（只在:value参数是Number类型时，才有效）；|

- - -

### addCharacter属性和replaceCharacterMap属性，区别：
```js
// 默认字符表；
characterMap: [',', '+', '-', '.', '9', '8', '7', '6', '5', '4', '3', '2', '1', '0']
```
- addCharacter：在默认的字符表基础上新增字符；
- replaceCharacterMap：用新的字符表，替换默认的字符表；
- 区别：后者可以控制字符表内字符的顺序；

### 通过.active-number类名，可以控制每个字符在激活状态下的样式，比如：
```css
.active-number {
  color: white;
  text-shadow: 1px 1px red,2px 2px red;
}
```
效果如下：

![avatar](https://github.com/hz-ljq/vue-number-counter/blob/master/src/assets/images/demo1.png)

---
_Source: https://npm.io/package/vue-number-counter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
