mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
refactor(components): [checkbox] set the label default value to undefined
(#14011)
* fix(components): [checkbox] allow the label value to be number 0 * fix: update computed * test: add test case * fix: update
This commit is contained in:
parent
0137d4cfcb
commit
e32cef1d1b
@ -21,6 +21,11 @@ describe('Checkbox', () => {
|
||||
expect(wrapper.classes('is-checked')).toBe(false)
|
||||
})
|
||||
|
||||
test('label set to number 0', async () => {
|
||||
const wrapper = mount(() => <Checkbox label={0} />)
|
||||
expect(wrapper.find('.el-checkbox__label').text()).toBe('0')
|
||||
})
|
||||
|
||||
describe('no v-model', () => {
|
||||
test('checkbox without label', async () => {
|
||||
const checked = ref(false)
|
||||
|
@ -20,6 +20,7 @@ export const checkboxProps = {
|
||||
*/
|
||||
label: {
|
||||
type: [String, Boolean, Number, Object],
|
||||
default: undefined,
|
||||
},
|
||||
/**
|
||||
* @description Set indeterminate state, only responsible for style control
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { computed, inject, ref, toRaw } from 'vue'
|
||||
import { isEqual } from 'lodash-unified'
|
||||
import { isEqual, isNil } from 'lodash-unified'
|
||||
import { useFormSize } from '@element-plus/components/form'
|
||||
import { isArray, isBoolean, isObject } from '@element-plus/utils'
|
||||
import { checkboxGroupContextKey } from '../constants'
|
||||
@ -41,7 +41,7 @@ export const useCheckboxStatus = (
|
||||
const checkboxSize = useFormSize(computed(() => checkboxGroup?.size?.value))
|
||||
|
||||
const hasOwnLabel = computed<boolean>(() => {
|
||||
return !!(slots.default || props.label)
|
||||
return !!slots.default || !isNil(props.label)
|
||||
})
|
||||
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user