mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
fix/typescripting-button-component
- Adding type definition for button component
This commit is contained in:
parent
5da603bffb
commit
393830f946
@ -22,9 +22,19 @@
|
||||
<span v-if="$slots.default"><slot></slot></span>
|
||||
</button>
|
||||
</template>
|
||||
<script>
|
||||
<script lang='ts'>
|
||||
import { computed, inject } from 'vue'
|
||||
const ELEMENT = {}
|
||||
const ELEMENT: {
|
||||
size?: number;
|
||||
} = {}
|
||||
// TODOS: replace these interface definition with actual ElForm interface
|
||||
interface ElForm {
|
||||
disabled: boolean;
|
||||
}
|
||||
interface ElFormItem {
|
||||
elFormItemSize: number;
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'ElButton',
|
||||
|
||||
@ -49,27 +59,21 @@ export default {
|
||||
round: Boolean,
|
||||
circle: Boolean
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleClick(evt) {
|
||||
this.$emit('click', evt);
|
||||
}
|
||||
},
|
||||
setup(props,ctx) {
|
||||
// inject
|
||||
const elForm = inject('elForm', '')
|
||||
const elFormItem = inject('elFormItem', '')
|
||||
const elForm = inject<ElForm>('elForm')
|
||||
const elFormItem = inject<ElFormItem>('elFormItem')
|
||||
|
||||
// computed
|
||||
const _elFormItemSize = computed(() => {
|
||||
return (elFormItem || {}).elFormItemSize
|
||||
return elFormItem.elFormItemSize || undefined
|
||||
})
|
||||
const buttonSize = computed(() => {
|
||||
// todo ELEMENT
|
||||
return props.size || _elFormItemSize.value || (ELEMENT || {}).size
|
||||
return props.size || _elFormItemSize.value || ELEMENT.size || undefined
|
||||
})
|
||||
const buttonDisabled = computed(() => {
|
||||
return props.disabled || (elForm || {}).disabled
|
||||
return props.disabled || elForm.disabled
|
||||
})
|
||||
|
||||
//methods
|
||||
|
Loading…
Reference in New Issue
Block a user