feat: add number-to-string conversion for api-checkbox-group, api-radio-group, and api-select components

pull/56/head
chenminjie 2024-12-03 17:45:08 +08:00
parent f85f1136c5
commit 50b9ef61b9
3 changed files with 36 additions and 0 deletions

View File

@ -119,6 +119,16 @@ watch(
},
{ deep: true },
);
// value mValue options value
watch(
() => props.value,
() => {
if (props.numberToString && Array.isArray(mValue.value)) {
mValue.value = mValue.value.map((item) => `${item}`);
}
},
);
</script>
<template>

View File

@ -123,6 +123,19 @@ watch(
},
{ deep: true },
);
// value mValue options value
watch(
() => props.value,
() => {
if (props.numberToString && typeof mValue.value === 'number') {
mValue.value = `${mValue.value}`;
}
if (props.numberToString && Array.isArray(mValue.value)) {
mValue.value = mValue.value.map((item) => `${item}`);
}
},
);
</script>
<template>

View File

@ -125,6 +125,19 @@ watch(
},
{ deep: true },
);
// value mValue options value
watch(
() => props.value,
() => {
if (props.numberToString && typeof mValue.value === 'number') {
mValue.value = `${mValue.value}`;
}
if (props.numberToString && Array.isArray(mValue.value)) {
mValue.value = mValue.value.map((item) => `${item}`);
}
},
);
</script>
<template>