feat: prefixCls

pull/802/head
mingyan.yu 2019-05-25 22:43:44 +08:00
parent 04ac500c2e
commit f4c0384d97
4 changed files with 28 additions and 11 deletions

View File

@ -2,7 +2,6 @@ import * as moment from 'moment';
import interopDefault from '../_util/interopDefault';
import { cloneElement } from '../_util/vnode';
import { initDefaultProps } from '../_util/props-util';
import Statistic, { StatisticProps } from './Statistic';
import { formatCountdown } from './utils';
@ -15,7 +14,6 @@ function getTime(value) {
export default {
name: 'AStatisticCountdown',
props: initDefaultProps(StatisticProps, {
prefixCls: 'ant-statistic',
format: 'HH:mm:ss',
}),

View File

@ -1,6 +1,6 @@
import PropTypes from '../_util/vue-types';
import { getComponentFromProp, initDefaultProps } from '../_util/props-util';
import { ConfigConsumerProps } from '../config-provider';
import StatisticNumber from './Number';
export const StatisticProps = {
@ -25,9 +25,20 @@ export default {
decimalSeparator: '.',
groupSeparator: ',',
}),
inject: {
configProvider: { default: () => ({}) },
},
render() {
const { prefixCls, value = 0, valueStyle, valueRender } = this.$props;
const {
prefixCls: customizePrefixCls,
value = 0,
valueStyle,
valueRender,
} = this.$props;
const getPrefixCls = this.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls;
const prefixCls = getPrefixCls('statistic', customizePrefixCls);
const title = getComponentFromProp(this, 'title');
let prefix = getComponentFromProp(this, 'prefix');
let suffix = getComponentFromProp(this, 'suffix');

View File

@ -1,6 +1,6 @@
## API
#### Statistic
### Statistic
| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
@ -14,13 +14,17 @@
| value | Display value | string \| number | - |
#### Statistic.Countdown
### Statistic.Countdown
| Property | Description | Type | Default |
| -------- | ----------- | ---- | ------- |
| format | Format as [moment](http://momentjs.com/) | string | 'HH:mm:ss' |
| onFinish | Trigger when time's up | () => void | - |
| prefix | prefix node of value | string \| VNode | - |
| suffix | suffix node of value | string \| VNode | - |
| title | Display title | string \| VNode | - |
| value | Set target countdown time | number \| moment | - |
| value | Set target countdown time | number \| moment | - |
#### Statistic.Countdown Events
| Events Name | Description | Arguments |
| --- | --- | --- |
| onFinish | Trigger when time's up | () => void | - |

View File

@ -1,6 +1,6 @@
## API
#### Statistic
### Statistic
| 参数 | 说明 | 类型 | 默认值 |
| -------- | ----------- | ---- | ------- |
@ -13,13 +13,17 @@
| title | 数值的标题 | string \| VNode | - |
| value | 数值内容 | string \| number | - |
#### Statistic.Countdown
### Statistic.Countdown
| 参数 | 说明 | 类型 | 默认值 |
| -------- | ----------- | ---- | ------- |
| format | 格式化倒计时展示,参考 [moment](http://momentjs.com/) | string | 'HH:mm:ss' |
| onFinish | 倒计时完成时触发 | () => void | - |
| prefix | 设置数值的前缀 | string \| VNode | - |
| suffix | 设置数值的后缀 | string \| VNode | - |
| title | 数值的标题 | string \| VNode | - |
| value | 数值内容 | number \| moment | - |
#### Statistic.Countdown事件
| 事件名称 | 说明 | 回调参数 |
| --- | --- | --- |
| onFinish | 倒计时完成时触发 | () => void |