[improvement] optimize sfc type definitions (#2778)

This commit is contained in:
neverland
2019-02-18 17:34:32 +08:00
committed by GitHub
parent 0013185d38
commit 78174e4550
8 changed files with 131 additions and 97 deletions

View File

@@ -4,15 +4,32 @@ import { routeProps, RouteProps, functionalRoute } from '../mixins/router';
import Loading from '../loading';
// Types
import { FunctionalComponent } from '../utils/use/sfc';
import { CreateElement, RenderContext } from 'vue/types';
import { DefaultSlots } from '../utils/use/sfc';
export type ButtonProps = RouteProps & {
tag?: string;
type?: string;
size?: string;
text?: string;
block?: boolean;
plain?: boolean;
round?: boolean;
square?: boolean;
loading?: boolean;
disabled?: boolean;
nativeType?: string;
loadingText?: string;
bottomAction?: boolean;
};
const [sfc, bem] = use('button');
const Button: FunctionalComponent<ButtonProps> = function (
h,
props,
slots,
ctx
function Button(
h: CreateElement,
props: ButtonProps,
slots: DefaultSlots,
ctx: RenderContext<ButtonProps>
) {
const { tag, type, disabled, loading, loadingText } = props;
@@ -55,23 +72,7 @@ const Button: FunctionalComponent<ButtonProps> = function (
)}
</tag>
);
};
export type ButtonProps = RouteProps & {
tag?: string;
type?: string;
size?: string;
text?: string;
block?: boolean;
plain?: boolean;
round?: boolean;
square?: boolean;
loading?: boolean;
disabled?: boolean;
nativeType?: string;
loadingText?: string;
bottomAction?: boolean;
};
}
Button.props = {
...routeProps,