Skip to content

Cascader 级联选择器

基本用法

级联选择器。

控制台
[
  "residents",
  "building_a"
]
查看代码
vue
<template>
	<demo-container class="gov-demo-cascader">
		<gov-cascader v-model="values" :options="options" />
		<template #console>
			{{ values }}
		</template>
	</demo-container>
</template>

<script setup>
import { ref } from "vue";
import options from "./data.js";

const values = ref(["residents", "building_a"]);
</script>

仅显示最后一级

属性 show-all-levels 定义了是否显示完整的路径,将其赋值为false则仅显示最后一级。

控制台
[
  "zujian",
  "form",
  "input-number"
]
查看代码
vue
<template>
	<demo-container class="gov-demo-cascader">
		<gov-cascader
			v-model="values"
			:options="options"
			:showAllLevels="false"
		/>
		<template #console>
			{{ values }}
		</template>
	</demo-container>
</template>

<script setup>
import { ref } from "vue";
import options from "./data.js";

const values = ref(["zujian", "form", "input-number"]);
</script>

Attributes

属性名说明类型可选值默认值
modelValue绑定的值,用于控制选中的级联菜单项Array[]
options级联菜单的数据选项Array[]
size输入框尺寸String
placeholder占位符String"请输入"
disabled是否禁用Booleantrue, falsefalse
clear是否显示清空按钮Booleantrue, falsetrue
showAllLevels是否显示完整的路径Booleantrue, falsetrue
triggerForm是否触发表单验证Booleantrue, falsetrue

Events

事件名说明回调参数
change选中项变化时触发选中项的值数组
focus输入框获得焦点时触发
blur输入框失去焦点时触发
clear清空按钮点击时触发
update:modelValue绑定值更新时触发选中项的值数组

Released under the MIT License.