Skip to content

Commit 5559e94

Browse files
committed
docs: update readme & demo
1 parent f7c0c30 commit 5559e94

File tree

3 files changed

+60
-59
lines changed

3 files changed

+60
-59
lines changed

README.md

+54-53
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,75 @@
11
# vue-countup-v3
22

3-
> Vue 3 component wrap for *countUp*.js
3+
> Vue 3 component wrap for *countUp.js*
44
55
## Installation
66

77
```bash
88
# npm
99
$ npm i countup.js vue-countup-v3 -S
10-
# yarn
10+
# or yarn
1111
$ yarn add countup.js vue-countup-v3 -S
1212
```
1313

1414
## Usage
1515

16-
**简单示例**
16+
**简单示例(simple usage)**
1717

1818
```vue
1919
<script setup lang="ts">
2020
import CountUp from 'vue-countup-v3'
2121
</script>
2222
2323
<template>
24-
<count-up :endVal="2000"></count-up>
24+
<count-up :end-val="2000"></count-up>
2525
</template>
26-
2726
```
2827

29-
**完整示例**
28+
<details>
29+
<summary style="font-weight:bold;">完整示例(full usage)</summary>
3030

31-
```vue
31+
```html
3232
<script setup lang="ts">
33-
import CountUpV3 from 'vue-countup-v3'
34-
import type { CountUp } from 'countup.js';
35-
// coutup.js options
36-
const options = {
37-
decimalPlaces: 2,
38-
// ...
39-
}
40-
const onInit = (countup: CountUp) => {
41-
console.log('init', countup)
42-
}
43-
const onFinished = () => {
44-
console.log('finished')
45-
}
33+
import CountUp from 'vue-countup-v3'
34+
import type { CountUp as ICountUp } from 'countup.js'
35+
// coutup.js options
36+
const options = {
37+
decimalPlaces: 2
38+
// ...
39+
}
40+
const onInit = (countup: ICountUp) => {
41+
console.log('init', countup)
42+
}
43+
const onFinished = () => {
44+
console.log('finished')
45+
}
4646
</script>
4747

4848
<template>
4949
<count-up
50-
:endVal="2000"
50+
:end-val="2000"
5151
:duration="3"
5252
:loop="2"
5353
:options="options"
5454
@init="onInit"
5555
@finished="onFinished"></count-up>
5656
</template>
57-
5857
```
5958

59+
</details>
60+
6061
## 组件属性(Component Properties)
6162

62-
**以下属性同 coutup.js 配置项**
63+
**以下属性同 coutup.js 配置项(same as countup.js properties)**
6364

64-
| Name | Type | Default | Description |
65-
| :------: | :--------------: | :-----: | :----------------------------------------------------------: |
66-
| endVal | Number \| String | - | 结束值 |
67-
| startVal | Number \| String | 0 | 起始值 |
68-
| duration | Number | 2.5 | 动画时长,单位:秒 |
69-
| options | Object | - | [countUp.js](https://github.com/inorganik/countUp.js) options 配置项 |
65+
| Name | Type | Default | Description |
66+
| :------: | :--------------: | :-----: | :------------------------------------------------------------------: |
67+
| endVal | Number \| String | - | 结束值 |
68+
| startVal | Number \| String | 0 | 起始值 |
69+
| duration | Number | 2.5 | 动画时长,单位:秒 |
70+
| options | Object | - | [countUp.js](https://github.com/inorganik/countUp.js) options 配置项 |
7071

71-
**以下为组件自有属性**
72+
**以下为组件拓展属性(extension properties)**
7273

7374
| Name | Type | Default | Description |
7475
| :------: | :---------------: | :-----: | :------------------------------------: |
@@ -77,52 +78,52 @@ const onFinished = () => {
7778

7879
## coutup.js 说明
7980

80-
see more [countUp.js](https://github.com/inorganik/countUp.js)
81+
see more [countUp.js](https://github.com/inorganik/countUp.js)
8182

8283
### 配置项(**Options**
8384

8485
```typescript
8586
interface CountUpOptions {
86-
startVal?: number; // number to start at (0) 开始数值,默认 0
87-
decimalPlaces?: number; // number of decimal places (0) 小数点 位数
88-
duration?: number; // animation duration in seconds (2) 动画时长
89-
useGrouping?: boolean; // example: 1,000 vs 1000 (true) 是否使用千分位
90-
useEasing?: boolean; // ease animation (true) 动画函数类型
91-
smartEasingThreshold?: number; // smooth easing for large numbers above this if useEasing (999)
92-
smartEasingAmount?: number; // amount to be eased for numbers above threshold (333)
93-
separator?: string; // grouping separator (',') 千位分隔符
94-
decimal?: string; // decimal ('.') 小数点分隔符
87+
startVal?: number // number to start at (0) 开始数值,默认 0
88+
decimalPlaces?: number // number of decimal places (0) 小数点 位数
89+
duration?: number // animation duration in seconds (2) 动画时长
90+
useGrouping?: boolean // example: 1,000 vs 1000 (true) 是否使用千分位
91+
useEasing?: boolean // ease animation (true) 动画函数类型
92+
smartEasingThreshold?: number // smooth easing for large numbers above this if useEasing (999)
93+
smartEasingAmount?: number // amount to be eased for numbers above threshold (333)
94+
separator?: string // grouping separator (',') 千位分隔符
95+
decimal?: string // decimal ('.') 小数点分隔符
9596
// easingFn: easing function for animation (easeOutExpo) 动画函数
96-
easingFn?: (t: number, b: number, c: number, d: number) => number;
97-
formattingFn?: (n: number) => string; // this function formats result 格式化结果
98-
prefix?: string; // text prepended to result 数值前缀
99-
suffix?: string; // text appended to result 数值后缀
100-
numerals?: string[]; // numeral glyph substitution 数字符号替换 0 - 9,例如替换为 [a,b,c,d,e,f,g,h,i,j]
101-
enableScrollSpy?: boolean; // start animation when target is in view 在可视范围内才开始动画
102-
scrollSpyDelay?: number; // delay (ms) after target comes into view 目标进入可视范围内后的延迟时间(毫秒)
97+
easingFn?: (t: number, b: number, c: number, d: number) => number
98+
formattingFn?: (n: number) => string // this function formats result 格式化结果
99+
prefix?: string // text prepended to result 数值前缀
100+
suffix?: string // text appended to result 数值后缀
101+
numerals?: string[] // numeral glyph substitution 数字符号替换 0 - 9,例如替换为 [a,b,c,d,e,f,g,h,i,j]
102+
enableScrollSpy?: boolean // start animation when target is in view 在可视范围内才开始动画
103+
scrollSpyDelay?: number // delay (ms) after target comes into view 目标进入可视范围内后的延迟时间(毫秒)
103104
}
104105
```
105106

106107
### **方法(Methods)**
107108

108-
Toggle pause/resume 切换暂停/回复
109+
Toggle pause/resume 切换暂停/恢复
109110

110111
```js
111-
countUp.pauseResume();
112+
countUp.pauseResume()
112113
```
113114

114115
Reset the animation: 重置数值
115116

116117
```js
117-
countUp.reset();
118+
countUp.reset()
118119
```
119120

120-
Update the end value and animate: 修改结束值
121+
Update the end value and animate: 修改结束值且继续动画
121122

122123
```js
123-
countUp.update(1000);
124+
countUp.update(1000)
124125
```
125126

126127
## License
127128

128-
MIT
129+
MIT

demo/App.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script setup lang="ts">
2-
import CountUpV3 from '../dist/vue-countup-v3.es.js'
3-
import type { CountUp } from 'countup.js'
2+
import CountUp from '../src/countup.vue'
3+
import type { CountUp as ICountUp } from 'countup.js'
44
const options = {
55
decimalPlaces: 2
66
}
7-
const onInit = (countup: CountUp) => {
7+
const onInit = (countup: ICountUp) => {
88
console.log('init', countup)
99
}
1010
const onFinished = () => {
@@ -14,14 +14,14 @@ const onFinished = () => {
1414

1515
<template>
1616
<div>vue countup</div>
17-
<count-up-v3
17+
<count-up
1818
class="coutup"
1919
:end-val="2000"
2020
:duration="3"
2121
:loop="2"
2222
:options="options"
2323
@init="onInit"
24-
@finished="onFinished"></count-up-v3>
24+
@finished="onFinished"></count-up>
2525
</template>
2626

2727
<style>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-countup-v3",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "Vue 3 component wrap for countUp.js",
55
"keywords": [
66
"vue3",

0 commit comments

Comments
 (0)