feat: add Checkbox and Radio field families
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CheckboxContent,
|
||||
CheckboxControl,
|
||||
CheckboxIndicator,
|
||||
Checkbox,
|
||||
Button,
|
||||
} 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 =
|
||||
"表单提交数据:\n" +
|
||||
Array.from(data)
|
||||
.map(([key, value]) => `${key}: ${value}`)
|
||||
.join("\n");
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<form class="flex flex-col gap-4" @submit.prevent="submit">
|
||||
<div class="flex flex-col gap-3">
|
||||
<Checkbox name="notifications" value="on">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
启用通知
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox default-selected name="newsletter" value="on">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
订阅新闻通讯
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
<Checkbox name="marketing" value="on">
|
||||
<CheckboxContent>
|
||||
<CheckboxControl>
|
||||
<CheckboxIndicator />
|
||||
</CheckboxControl>
|
||||
接收营销更新
|
||||
</CheckboxContent>
|
||||
</Checkbox>
|
||||
</div>
|
||||
<Button class="mt-4" size="sm" type="submit" variant="primary">提交</Button>
|
||||
<pre v-if="result" role="status" class="whitespace-pre-wrap text-sm">{{
|
||||
result
|
||||
}}</pre>
|
||||
</form>
|
||||
</template>
|
||||
Reference in New Issue
Block a user