diff --git a/packages/varlet-ui/src/button/Button.vue b/packages/varlet-ui/src/button/Button.vue index a9719ec9d50..5def4fecb7f 100644 --- a/packages/varlet-ui/src/button/Button.vue +++ b/packages/varlet-ui/src/button/Button.vue @@ -16,7 +16,11 @@ :disabled="disabled" @click="trigger" > - + diff --git a/packages/varlet-ui/src/button/example/index.vue b/packages/varlet-ui/src/button/example/index.vue index 62a3f302507..4f3240fa86a 100644 --- a/packages/varlet-ui/src/button/example/index.vue +++ b/packages/varlet-ui/src/button/example/index.vue @@ -1,20 +1,5 @@ diff --git a/packages/varlet-ui/src/button/propsEmits.ts b/packages/varlet-ui/src/button/propsEmits.ts index dd09a5cdc29..02962924cb5 100644 --- a/packages/varlet-ui/src/button/propsEmits.ts +++ b/packages/varlet-ui/src/button/propsEmits.ts @@ -1,3 +1,9 @@ +import { + typeValidator as loadingTypeValidator, + sizeValidator as loadingSizeValidator, + getTypeDefault as getLoadingTypeDefault +} from '../loading/propsEmits' + function typeValidator(type: string): boolean { const validTypes = ['plain', 'primary', 'info', 'success', 'warning', 'danger'] @@ -28,6 +34,18 @@ export const props = { type: Boolean, default: false }, + // 加载动画类型 + loadingType: { + type: String, + default: getLoadingTypeDefault, + validator: loadingTypeValidator + }, + // 加载动画尺寸 + loadingSize: { + type: String, + default: (props: any) => props.size, + validator: loadingSizeValidator + }, // 原型按钮 round: { type: Boolean, diff --git a/packages/varlet-ui/src/loading/propsEmits.ts b/packages/varlet-ui/src/loading/propsEmits.ts index d75166c1961..85e91629bff 100644 --- a/packages/varlet-ui/src/loading/propsEmits.ts +++ b/packages/varlet-ui/src/loading/propsEmits.ts @@ -1,25 +1,29 @@ -function typeValidator(type: string): boolean { +export function typeValidator(type: string): boolean { const validTypes = ['wave', 'cube', 'rect', 'disappear'] return validTypes.includes(type) } -function sizeValidator(size: string): boolean { +export function sizeValidator(size: string): boolean { const validSizes = ['normal', 'mini', 'small', 'large'] return validSizes.includes(size) } +export const getTypeDefault = () => 'wave' + +export const getSizeDefault = () => 'normal' + export const props = { // loading类型 type: { type: String, - default: 'wave', + default: getTypeDefault, validator: typeValidator, }, // loading尺寸 size: { type: String, - default: 'normal', + default: getSizeDefault, validator: sizeValidator, }, // loading颜色