mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-06 10:38:31 +08:00
fix: [el-form] button type is reset and reset form (#3445)
* fix: [el-form] button type is reset and reset form * fix: [el-form] button type is reset and reset form * fix: [el-form] button type is reset and reset form
This commit is contained in:
parent
9a160450ea
commit
f66b046872
@ -24,25 +24,32 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import isEmpty from 'lodash/isEmpty'
|
||||
import { computed, inject, defineComponent } from 'vue'
|
||||
import { useFormItem } from '@element-plus/hooks'
|
||||
import { elButtonGroupKey } from '@element-plus/tokens'
|
||||
import { elButtonGroupKey, elFormKey } from '@element-plus/tokens'
|
||||
|
||||
import { buttonEmits, buttonProps } from './button'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ElButton',
|
||||
|
||||
props: buttonProps,
|
||||
emits: buttonEmits,
|
||||
|
||||
setup(_, { emit }) {
|
||||
setup(props, { emit }) {
|
||||
const elBtnGroup = inject(elButtonGroupKey, undefined)
|
||||
const { size: buttonSize, disabled: buttonDisabled } = useFormItem({
|
||||
size: computed(() => elBtnGroup?.size),
|
||||
})
|
||||
|
||||
const handleClick = (evt: MouseEvent) => emit('click', evt)
|
||||
const elForm = inject(elFormKey, undefined)
|
||||
|
||||
const handleClick = (evt: MouseEvent) => {
|
||||
if (props.nativeType === 'reset' && !isEmpty(elForm)) {
|
||||
elForm?.resetFields()
|
||||
}
|
||||
emit('click', evt)
|
||||
}
|
||||
|
||||
return {
|
||||
buttonSize,
|
||||
|
Loading…
Reference in New Issue
Block a user