avue中:单选框、复选框、下拉框多选

本文介绍了前端开发中三种常见的表单组件——单选框、复选框和下拉框的实现,特别是在多选模式下,利用字典接口动态加载选项。每个组件的示例代码展示了如何通过`dicUrl`获取字典数据,以及如何设置`props`来绑定显示值和实际值。这些组件在数据验证和用户交互中扮演着关键角色。
摘要由CSDN通过智能技术生成

单选框、复选框、下拉框、下拉多选框,都需要使用字典进行选择框中值的定义

1.单选框

{
            label: "风险类型",
            type: "radio",     //单选框
            dicUrl: "/api/blade-system/dict/dictionary?code=risk_type",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            slot: true,
            prop: "riskType",
            rules: [
              {
                required: true,
                message: "请输入风险类型",
                trigger: "blur",
              },
            ],
          },

效果图:

2.复选框:

{
            label: "风险类型",
            type: "checkbox",   //复选框
            dicUrl: "/api/blade-system/dict/dictionary?code=risk_type",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            slot: true,
            prop: "riskType",
            rules: [
              {
                required: true,
                message: "请输入风险类型",
                trigger: "blur",
              },
            ],
          },

效果图:

 

3.下拉框多选 

{
            label: "风险类型",
            type: "select",   //下拉框类型
            multiple: true,   //将可选变为多选
            dicUrl: "/api/blade-system/dict/dictionary?code=risk_type",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            slot: true,
            prop: "riskType",
            rules: [
              {
                required: true,
                message: "请输入风险类型",
                trigger: "blur",
              },
            ],
          },

效果图:

 

 

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值