Skip to content

介绍


本文档主要用于描述 ShadcnInput 组件的一些特性和用法。

用法

查看代码
vue
<template>
    <ShadcnInput v-model="input" placeholder="Input" />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const input = ref('')
</script>

清空 (clearable)

查看代码
vue
<template>
    <ShadcnInput v-model="input" placeholder="Input" clearable />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const input = ref('Hello View Shadcn UI')
</script>

尺寸 (size)

查看代码
vue
<template>
    <ShadcnInput v-model="input" placeholder="Input" size="small" />
    <ShadcnInput v-model="input" placeholder="Input" size="default"/>
    <ShadcnInput v-model="input" placeholder="Input" size="large" />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const input = ref('Hello View Shadcn UI')
</script>

字数统计 (word-count)

查看代码
vue
<template>
    <ShadcnInput v-model="input" placeholder="Input" word-count />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const input = ref('Hello View Shadcn UI')
</script>

最大统计值 (max-count)

查看代码
vue
<template>
    <ShadcnInput v-model="input" placeholder="Input" word-count :max-count="100" />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const input = ref('Hello View Shadcn UI')
</script>

前缀 & 后缀 (prefix & suffix)

查看代码
vue
<template>
    <ShadcnInput v-model="input" placeholder="Input">
        <template #prefix>
            <span class="text-xs text-gray-300">P</span>
        </template>
        <template #suffix>
            <span class="text-xs text-gray-300">S</span>
        </template>
    </ShadcnInput>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const input = ref('Hello View Shadcn UI')
</script>

禁用 (disabled)

查看代码
vue
<template>
    <ShadcnInput v-model="input" placeholder="Input" disabled />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const input = ref('Hello View Shadcn UI')
</script>

密码 (password)

查看代码
vue
<template>
    <ShadcnInput v-model="input" placeholder="Input" type="password" />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const input = ref('Hello View Shadcn UI')
</script>

多行文本 (textarea)

查看代码
vue
<template>
    <ShadcnInput v-model="input" placeholder="Input" type="textarea" />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const input = ref('Hello View Shadcn UI')
</script>

表单 (form)

输入框 (Input) 属性

输入框 (Input) 事件

输入框 (Input) 插槽