refactor: rate to ts

feat-dayjs^2
Amour1688 2020-10-20 10:10:10 +08:00
parent ab9ab87242
commit 9350a332b3
2 changed files with 8 additions and 8 deletions

View File

@ -1,4 +1,4 @@
import { inject } from 'vue'; import { inject, defineComponent } from 'vue';
import omit from 'omit.js'; import omit from 'omit.js';
import PropTypes from '../_util/vue-types'; import PropTypes from '../_util/vue-types';
import { getOptionProps, getComponent } from '../_util/props-util'; import { getOptionProps, getComponent } from '../_util/props-util';
@ -10,8 +10,8 @@ import Tooltip from '../tooltip';
export const RateProps = { export const RateProps = {
prefixCls: PropTypes.string, prefixCls: PropTypes.string,
count: PropTypes.number, count: PropTypes.number,
value: PropTypes.value, value: PropTypes.number,
defaultValue: PropTypes.value, defaultValue: PropTypes.number,
allowHalf: PropTypes.looseBool, allowHalf: PropTypes.looseBool,
allowClear: PropTypes.looseBool, allowClear: PropTypes.looseBool,
tooltips: PropTypes.arrayOf(PropTypes.string), tooltips: PropTypes.arrayOf(PropTypes.string),
@ -20,7 +20,7 @@ export const RateProps = {
autofocus: PropTypes.looseBool, autofocus: PropTypes.looseBool,
}; };
const Rate = { const Rate = defineComponent({
name: 'ARate', name: 'ARate',
props: RateProps, props: RateProps,
setup() { setup() {
@ -35,15 +35,15 @@ const Rate = {
return <Tooltip title={tooltips[index]}>{node}</Tooltip>; return <Tooltip title={tooltips[index]}>{node}</Tooltip>;
}, },
focus() { focus() {
this.$refs.refRate.focus(); (this.$refs.refRate as any).focus();
}, },
blur() { blur() {
this.$refs.refRate.blur(); (this.$refs.refRate as any).blur();
}, },
}, },
render() { render() {
const { prefixCls: customizePrefixCls, ...restProps } = getOptionProps(this); const { prefixCls: customizePrefixCls, ...restProps } = getOptionProps(this);
const getPrefixCls = this.configProvider.getPrefixCls; const { getPrefixCls } = this.configProvider;
const prefixCls = getPrefixCls('rate', customizePrefixCls); const prefixCls = getPrefixCls('rate', customizePrefixCls);
const character = getComponent(this, 'character') || <StarFilled />; const character = getComponent(this, 'character') || <StarFilled />;
@ -57,7 +57,7 @@ const Rate = {
}; };
return <VcRate {...rateProps} />; return <VcRate {...rateProps} />;
}, },
}; });
/* istanbul ignore next */ /* istanbul ignore next */
Rate.install = function(app) { Rate.install = function(app) {