feat:默认选中

This commit is contained in:
dzc committed 2025-04-01 12:56:51 +08:00
1 parent f243e0330a
commit f3cf7a5054
15 files changed
+730 -248

No files matched your search

+9
View File
@@ -35,11 +35,13 @@ const props = withDefaults(
defineProps<{
placeholder?: string
apiParams?: any
autoFirst?: boolean
disabled?: boolean
}>(),
{
placeholder: "请选择",
apiParams: {},
autoFirst: false,
disabled: false,
},
)
@@ -75,6 +77,9 @@ async function getOptions() {
}
const { data } = await mchApi.select(_pa)
state.options = data.records ?? []
if (props.autoFirst && state.options.length != 0) {
state.selectId = state.options[0].id
}
} finally {
setTimeout(() => (state.loading = false), 500)
}
@@ -91,4 +96,8 @@ function clear() {
state.selectId = null
getOptions()
}
onMounted(() => {
props.autoFirst && getOptions()
})
</script>