feat: initialize Vue component library and aligned documentation
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
SwitchGroup,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function submit(event: Event) {
|
||||
const values = [...new FormData(event.target as HTMLFormElement).entries()];
|
||||
result.value = values.length
|
||||
? "表单提交内容:" + values.map(([k, v]) => `${k}: ${v}`).join(",")
|
||||
: "未选择任何选项";
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<form class="flex flex-col gap-4" @submit.prevent="submit">
|
||||
<SwitchGroup>
|
||||
<Switch name="notifications" value="on">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
启用通知
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch default-selected name="newsletter" value="on">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
订阅新闻简报
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch name="marketing" value="on">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
接收营销更新
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</SwitchGroup>
|
||||
<div class="flex gap-2">
|
||||
<Button class="mt-4" size="sm" type="submit">Submit</Button>
|
||||
<Button
|
||||
class="mt-4"
|
||||
size="sm"
|
||||
type="reset"
|
||||
variant="secondary"
|
||||
@click="result = ''"
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
</div>
|
||||
<output v-if="result" class="text-sm text-muted" aria-live="polite">
|
||||
{{ result }}
|
||||
</output>
|
||||
</form>
|
||||
</template>
|
||||
Reference in New Issue
Block a user