Skip to content

Checkbox

基础用法

标签

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

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

const tagList = [
  { dictLabel: '标签1', dictKey: 't1' },
  { dictLabel: '标签2', dictKey: 't2' },
  { dictLabel: '标签3', dictKey: 't3' },
]

const formInfo = reactive({
  tags: [],
})

const formConfig = computed(() => {
  return [
    {
      key: 'tags',
      label: '标签',
      type: 'checkbox',
      model: 'tags',
      prop: 'tags',
      width: 24,
      required: true,
      dictList: tagList
    },
  ]
})
</script>

Props

属性说明类型默认值
typecheckboxstring-
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-
dictList选项的数据源array[]
dictKey指定选项的值为选项对象的某个属性值stringdictKey
dictLabel指定节点标签为节点对象的某个属性值stringdictLabel
min可被勾选的 checkbox 的最小数量number-
max可被勾选的 checkbox 的最大数量number-
fill当按钮为活跃状态时的边框和背景颜色string-
isButtonbutton按钮样式booleanfalse
showErrorTooltip是否展示错误提示booleantrue
changeFun当绑定值变化时触发的回调函数Function-
showFun是否展示的判断函数,返回一个booleanFunction-