Skip to content

Cascader类型

基础用法

归属地区

<template>
  <ai-form ref="formEl" :model="formInfo" :formConfig="formConfig"></ai-form>
</template>

<script setup>
import { reactive, computed } from 'vue'

const regionOptions = [
  {
    value: 'cn',
    label: '中国',
    children: [
      { value: 'bg', label: '北京' },
      { value: 'cq', label: '重庆' }
    ]
  },
  {
    value: 'en',
    label: '英国',
    children: [{ value: 'lo', label: '伦敦' }]
  },
]

const formInfo = reactive({
  region: '',
})

const formConfig = computed(() => {
  return [
    {
      key: "region",
      label: "归属地区",
      type: "cascader",
      model: "region",
      prop: "region",
      required: true,
      dictList: regionOptions,
      dictKey: "value",
      dictLabel: "label",
    },
  ]
})
</script>

Props

属性说明类型默认值
typecascaderstring-
key配置列表唯一标识string-
label标签文本string-
model属性名,它可以是属性的路径(如a.b.0)也可以是一个方法,返回属性路径,该属性是必填的string/Function-
prop一般和属性名保持一致,在使用了validateresetFields的方法时,该属性是必填的string/Function-
width宽度(1-24)number12
noneLabel是否隐藏标签booleanfalse
placeholder输入框占位文本string-
disabled是否禁用boolean/Functionfalse
size输入框尺寸string-
required是否必填booleanfalse
validator自定义校验方法Function-
multiple是否多选booleanfalse
dictList选项的数据源array[]
dictKey指定选项的值为选项对象的某个属性值stringdictKey
dictLabel指定节点标签为节点对象的某个属性值stringdictLabel
clearable是否可以清空选项booleantrue
filterable是否可筛选booleanfalse
filterMethod自定义筛选方法的第一个参数是当前输入的值Function-
teleported弹层是否使用teleportbooleantrue
showErrorTooltip是否展示错误提示booleantrue
changeFun当绑定值变化时触发的回调函数Function-
showFun是否展示的判断函数,返回一个booleanFunction-