diff --git a/packages/vant/src/number-keyboard/NumberKeyboard.tsx b/packages/vant/src/number-keyboard/NumberKeyboard.tsx index 4a702d161..bde3a6f94 100644 --- a/packages/vant/src/number-keyboard/NumberKeyboard.tsx +++ b/packages/vant/src/number-keyboard/NumberKeyboard.tsx @@ -123,7 +123,9 @@ export default defineComponent({ const { extraKey } = props; const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey]; - if (extraKeys.length === 1) { + if (extraKeys.length === 0) { + keys.push({ text: 0, wider: true }); + } else if (extraKeys.length === 1) { keys.push( { text: 0, wider: true }, { text: extraKeys[0], type: 'extra' }, diff --git a/packages/vant/src/number-keyboard/test/__snapshots__/index.spec.ts.snap b/packages/vant/src/number-keyboard/test/__snapshots__/index.spec.ts.snap index c86be78a9..9afba9c93 100644 --- a/packages/vant/src/number-keyboard/test/__snapshots__/index.spec.ts.snap +++ b/packages/vant/src/number-keyboard/test/__snapshots__/index.spec.ts.snap @@ -61,3 +61,13 @@ exports[`should render title-left slot correctly 1`] = ` `; + +exports[`should render zero key correctly when extra-key prop is an empty array 1`] = ` +