外观
Questionnaire 分步问卷
用具名问题收集选择或文本回答,可逐步导航、标记必填项并提交表单。
import { SQuestionnaire } from '@icecreamqaq/shadcn/questionnaire'使用示例
常用 API
| 成员 | 类型 | 用法 |
|---|---|---|
SQuestionnaire.items | readonly QuestionnaireItemDefinition[] | 按名称定义题目顺序,可为题目指定选项顺序。 |
SQuestionnaire.v-model:item | string | 双向绑定当前题目的 name。 |
SQuestionnaireItem.name | string | 必填。既是题目标识,也是表单提交中的字段名。 |
SQuestionnaireItem.required | boolean | 启用后,当前题必须回答才能继续。 |
SQuestionnaire.@submit | (event: Event) => void | 验证通过后触发,用 FormData 从原生表单读取答案。 |
完整 API
Questionnaire13 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
defaultItem | string |
item | string |
items | readonly QuestionnaireItemDefinition[] |
noValidate | boolean |
shortcuts | QuestionnaireShortcutMode |
事件
| 名称 | 类型 |
|---|---|
reset | ((event: Event) => any) |
submit | ((event: Event) => any) |
update:item | ((item: string) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: { current: number; first: boolean; last: boolean; total: number; }) => any) |
title | ((props: { item: QuestionnaireItemDefinition; }) => any) |
choice | ((props: { item: QuestionnaireItemDefinition; choice: QuestionnaireChoiceDefinition; }) => any) |
actions | ((props: {}) => any) |
QuestionnaireActions4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
QuestionnaireChoice8 个成员
属性
| 名称 | 类型 |
|---|---|
checked | boolean |
class | ClassValue |
defaultChecked | boolean |
disabled | boolean |
value 必填 | string |
事件
| 名称 | 类型 |
|---|---|
change | ((event: Event) => any) |
update:checked | ((checked: boolean) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: { checked: boolean; disabled: boolean; shortcut: string | null; type: string; }) => any) |
QuestionnaireChoiceDescription2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
QuestionnaireChoices4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: { shortcuts: QuestionnaireShortcutMode | null; }) => any) |
QuestionnaireDescription5 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
id | string |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
QuestionnaireError5 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
id | string |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: { invalid: boolean; }) => any) |
QuestionnaireInput6 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
defaultValue | string | number |
disabled | boolean |
modelValue | string | number |
type | QuestionnaireInputType |
事件
| 名称 | 类型 |
|---|---|
update:modelValue | ((value: string) => any) |
QuestionnaireItem11 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
disabled | boolean |
invalid | boolean |
multiple | boolean |
skipped | boolean |
defaultSkipped | boolean |
name 必填 | string |
required | boolean |
事件
| 名称 | 类型 |
|---|---|
update:status | ((status: QuestionnaireItemStatus) => any) |
update:skipped | ((skipped: boolean) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: { active: boolean; invalid: boolean; status: QuestionnaireItemStatus; }) => any) |
QuestionnaireNext8 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
disabled | boolean |
size | "default" | "icon" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null |
variant | "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null |
事件
| 名称 | 类型 |
|---|---|
click | ((event: MouseEvent) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
QuestionnairePrevious8 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
disabled | boolean |
size | "default" | "icon" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null |
variant | "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null |
事件
| 名称 | 类型 |
|---|---|
click | ((event: MouseEvent) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
QuestionnaireProgress4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: { current: number; first: boolean; last: boolean; total: number; }) => any) |
QuestionnaireSkip8 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
disabled | boolean |
size | "default" | "icon" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null |
variant | "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null |
事件
| 名称 | 类型 |
|---|---|
click | ((event: MouseEvent) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
QuestionnaireSubmit7 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
disabled | boolean |
size | "default" | "icon" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null |
variant | "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
QuestionnaireTitle5 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
id | string |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
分组导出
模板标签为 <s-questionnaire>。
组件 SQuestionnaire、SQuestionnaireActions、SQuestionnaireChoice、SQuestionnaireChoiceDescription、SQuestionnaireChoices、SQuestionnaireDescription、SQuestionnaireError、SQuestionnaireInput、SQuestionnaireItem、SQuestionnaireNext、SQuestionnairePrevious、SQuestionnaireProgress、SQuestionnaireSkip、SQuestionnaireSubmit、SQuestionnaireTitle
函数与常量 injectQuestionnaireItemContext、injectQuestionnaireRootContext
类型 QuestionnaireChoiceDefinition、QuestionnaireInputType、QuestionnaireItemDefinition、QuestionnaireItemStatus、QuestionnaireShortcutMode