-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ 调整Statistic为CountTo组件并使用useCountDown重构
- Loading branch information
1 parent
661603a
commit a01baaf
Showing
14 changed files
with
327 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<frame/> | ||
|
||
# CountTo 数字滚动<el-tag text style="vertical-align: middle;margin-left:8px;" effect="plain">$LOWEST_VERSION$</el-tag> | ||
|
||
## 基本用法 | ||
|
||
设置 `endVal` 属性,表示最终值。 | ||
设置 `startVal` 属性,表示起始值。 | ||
设置 `duration` 属性,表示从起始值到结束值数字变动的时间。 | ||
设置 `autoplay` 属性,表示是否自动播放。 | ||
设置 `decimals` 属性,表示保留的小数位数。 | ||
设置 `decimal` 属性,表示小数点符号。 | ||
设置 `prefix` 属性,表示数字前缀。 | ||
设置 `suffix` 属性,表示数字后缀。 | ||
设置 `fontSize` 属性,表示字体大小。 | ||
设置 `color` 属性,表示文本颜色。 | ||
|
||
```vue | ||
<wd-count-to :endVal="2024" suffix="年" color="#16baaa"></wd-count-to> | ||
<wd-count-to prefix="¥" :startVal="0" :decimals="2" :endVal="186.321" :fontSize="32" suffix="%" color="#1e9fff"></wd-count-to> | ||
<wd-count-to prefix="¥" :startVal="0" :decimals="2" :endVal="21286.321" :fontSize="32" suffix="%" color="#ff5722"></wd-count-to> | ||
<wd-count-to prefix="¥" :startVal="0" :decimals="2" :endVal="21286.321" :fontSize="32" suffix="%" color="#ffb800" :duration="2000"></wd-count-to> | ||
``` | ||
|
||
## 手动控制 | ||
|
||
通过 `start` 方法开始倒计时,通过 `pause` 方法暂停倒计时,通过 `reset` 方法重置倒计时。 | ||
|
||
```html | ||
<wd-count-to | ||
ref="countTo" | ||
:auto-start="false" | ||
prefix="¥" | ||
:startVal="1000" | ||
:decimals="3" | ||
:endVal="9999.32" | ||
:fontSize="32" | ||
suffix="%" | ||
color="#1e9fff" | ||
></wd-count-to> | ||
<wd-grid clickable border> | ||
<wd-grid-item text="开始" icon="play-circle-stroke" @itemclick="start" /> | ||
<wd-grid-item text="暂停" icon="pause-circle" @itemclick="pause" /> | ||
<wd-grid-item text="重置" icon="refresh" @itemclick="reset" /> | ||
</wd-grid> | ||
``` | ||
|
||
```ts | ||
import type { CountToInstance } from '@/uni_modules/wot-design-uni/components/wd-count-to/types' | ||
|
||
const countTo = ref<CountToInstance>() | ||
|
||
const start = () => { | ||
countTo.value!.start() | ||
} | ||
const pause = () => { | ||
countTo.value!.pause() | ||
} | ||
const reset = () => { | ||
countTo.value!.reset() | ||
} | ||
``` | ||
|
||
## Attributes | ||
|
||
| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 | | ||
| --------- | ------------------------------ | ------- | -------------- | ------- | ---------------- | | ||
| fontSize | 字体大小 | number | 16 | default | $LOWEST_VERSION$ | | ||
| color | 文本颜色 | string | - | '' | $LOWEST_VERSION$ | | ||
| startVal | 起始值 | number | - | 0 | $LOWEST_VERSION$ | | ||
| endVal | 最终值 | number | - | 2024 | $LOWEST_VERSION$ | | ||
| duration | 从起始值到结束值数字变动的时间 | number | - | 3000 | $LOWEST_VERSION$ | | ||
| autoplay | 是否自动播放 | boolean | - | true | $LOWEST_VERSION$ | | ||
| decimals | 保留的小数位数 | number | (需大于等于 0) | 0 | $LOWEST_VERSION$ | | ||
| decimal | 小数点符号 | string | - | '.' | $LOWEST_VERSION$ | | ||
| separator | 三位三位的隔开效果 | string | - | ',' | $LOWEST_VERSION$ | | ||
| prefix | 前缀 | string | - | - | $LOWEST_VERSION$ | | ||
| suffix | 后缀 | string | - | - | $LOWEST_VERSION$ | | ||
| useEasing | 是否具有连贯性 | boolean | - | true | $LOWEST_VERSION$ | | ||
|
||
## Events | ||
|
||
| 事件名称 | 说明 | 参数 | 最低版本 | | ||
| -------- | -------------------- | ---- | ---------------- | | ||
| finish | 动画完成时触发 | — | $LOWEST_VERSION$ | | ||
| mounted | 组件加载完成时时触发 | - | $LOWEST_VERSION$ | | ||
|
||
## Methods | ||
|
||
| 方法名 | 说明 | 参数 | 最低版本 | | ||
| ------ | ----------------------------------------------------------- | ---- | ---------------- | | ||
| start | 开始动画 | — | $LOWEST_VERSION$ | | ||
| pause | 暂停动画 | — | $LOWEST_VERSION$ | | ||
| reset | 重置动画,若 `auto-start` 为 `true`,重设后会自动开始倒计时 | — | $LOWEST_VERSION$ | | ||
|
||
## Slots | ||
|
||
| 名称 | 说明 | 最低版本 | | ||
| ---- | -------- | -------- | | ||
| default | 默认插槽 | $LOWEST_VERSION$ | | ||
| prefix | 前缀插槽 | $LOWEST_VERSION$ | | ||
| suffix | 后缀插槽 | $LOWEST_VERSION$ | | ||
|
||
## 外部样式类 | ||
|
||
| 类名 | 说明 | 最低版本 | | ||
| ------------ | ---------- | ---------------- | | ||
| custom-class | 根节点样式 | $LOWEST_VERSION$ | | ||
| custom-style | 根节点样式 | $LOWEST_VERSION$ | |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<page-wraper> | ||
<demo-block title="基本用法"> | ||
<wd-count-to :endVal="endVal" suffix="年" color="#16baaa"></wd-count-to> | ||
<wd-count-to prefix="¥" :decimals="2" :endVal="186.321" :fontSize="32" suffix="%" color="#1e9fff"></wd-count-to> | ||
<wd-count-to prefix="¥" :decimals="2" :endVal="21286.321" :fontSize="32" suffix="%" color="#ff5722"></wd-count-to> | ||
<wd-count-to prefix="¥" :decimals="2" :endVal="21286.321" :fontSize="32" suffix="%" color="#ffb800" :duration="2000"></wd-count-to> | ||
</demo-block> | ||
|
||
<demo-block title="手动控制"> | ||
<wd-count-to | ||
ref="countTo" | ||
:auto-start="false" | ||
prefix="¥" | ||
:startVal="1000" | ||
:decimals="3" | ||
:endVal="9999.32" | ||
:fontSize="32" | ||
suffix="%" | ||
color="#1e9fff" | ||
></wd-count-to> | ||
|
||
<wd-grid clickable border> | ||
<wd-grid-item text="开始" icon="play-circle-stroke" @itemclick="start" /> | ||
<wd-grid-item text="暂停" icon="pause-circle" @itemclick="pause" /> | ||
<wd-grid-item text="重置" icon="refresh" @itemclick="reset" /> | ||
</wd-grid> | ||
</demo-block> | ||
</page-wraper> | ||
</template> | ||
<script lang="ts" setup> | ||
import type { CountToInstance } from '@/uni_modules/wot-design-uni/components/wd-count-to/types' | ||
import { ref } from 'vue' | ||
const endVal = ref<number>(2024) | ||
const countTo = ref<CountToInstance>() | ||
const start = () => { | ||
countTo.value!.start() | ||
} | ||
const pause = () => { | ||
countTo.value!.pause() | ||
} | ||
const reset = () => { | ||
countTo.value!.reset() | ||
} | ||
</script> | ||
<style lang="scss" scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
@import '../common/abstracts/mixin'; | ||
|
||
|
||
.wd-statistic{ | ||
.wd-count-to{ | ||
vertical-align: bottom; | ||
} |
Oops, something went wrong.