Files
heroui-vue/apps/docs/demos/number-field-controlled.vue
T

32 lines
908 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { ref } from "vue";
import {
Button,
Description,
Label,
NumberField,
NumberFieldGroup,
NumberFieldInput,
NumberFieldIncrementButton,
NumberFieldDecrementButton,
} from "@heroui-vue/components";
const value = ref<number | null>(1024);
</script>
<template>
<div class="flex w-full max-w-64 flex-col gap-4">
<NumberField v-model="value" :min-value="0" name="width">
<Label>宽度</Label>
<NumberFieldGroup>
<NumberFieldDecrementButton />
<NumberFieldInput class="w-[120px]" />
<NumberFieldIncrementButton />
</NumberFieldGroup>
<Description>当前值:{{ value }}</Description>
</NumberField>
<div class="flex gap-2">
<Button variant="tertiary" @click="value = 0">重置为 0</Button>
<Button variant="tertiary" @click="value = 2048">设为 2048</Button>
</div>
</div>
</template>