Skip to content

Radio

基础用法

角色

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

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

const roleOptions = [
  { dictKey: 2, dictLabel: '研发' },
  { dictKey: 3, dictLabel: '产品' },
  { dictKey: 4, dictLabel: '运营' }
]

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

const formConfig = computed(() => {
  return [
    {
      key: 'role',
      label: '角色',
      type: 'radio',
      model: 'role',
      prop: 'role',
      required: true,
      isButton: true,
      dictList: roleOptions
    },
  ]
})
</script>

Props

属性说明类型默认值
typeradiostring-
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
fill当按钮为活跃状态时的边框和背景颜色string-
isButtonbutton按钮样式booleanfalse
showErrorTooltip是否展示错误提示booleantrue
changeFun当绑定值变化时触发的回调函数Function-
showFun是否展示的判断函数,返回一个booleanFunction-