feat: add Checkbox and Radio field families
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxGroup,
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Label,
|
||||
FieldError,
|
||||
Button,
|
||||
Form,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function submit(event: Event) {
|
||||
const data = new FormData(event.currentTarget as HTMLFormElement);
|
||||
result.value = "已选偏好:" + data.getAll("preferences").join(", ");
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Form class="flex flex-col gap-4 px-4" @submit.prevent="submit">
|
||||
<CheckboxGroup is-required name="preferences">
|
||||
<Label>偏好设置</Label>
|
||||
<Checkbox value="email">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
邮件通知
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox value="sms">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
短信通知
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox value="push">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
推送通知
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<FieldError>请至少选择一种通知方式。</FieldError>
|
||||
</CheckboxGroup>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="result" role="status" class="text-sm">{{ result }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
Reference in New Issue
Block a user