el-select控制单选还是多选


multiple表示多选,:multiple-limit="1" 限制多选的条数为1,2就是选两个,依此类推。为0 就是不限制选几个
使用 allow-create 属性即可通过在输入框中输入文字来创建新的条目。注意此时 filterable 必须为真。

php 复制代码
  <el-form :inline="true" :model="form" class="demo-form-inline">
      <el-select v-model="form.properties_id" style="width: 300px" placeholder="请选择样品性质" filterable clearable multiple @change="getData()" :multiple-limit="limit_properties">
        <el-option v-for="item in sample_properties" :label="item.label" :value="item.value" :key="item.value"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-select v-model="form.place_id" style="width: 300px" placeholder="请选择品名" filterable clearable multiple @change="getData()" :multiple-limit="limit_place">
        <el-option v-for="item in place_data" :label="item.label" :value="item.value" :key="item.value"></el-option>
      </el-select>
    </el-form-item>
  </el-form>
javascript 复制代码
    data() {
      return {
        sample_properties:@json($sample_properties),
        place_data:@json($place_data),
        form: {
          properties_id : [],
          place_id      : [],
        },
        limit_properties : 0,
        limit_place : 0,
      }
    },

   methods: {
     getData(){
        var that = this
        if(that.form.properties_id.length>1 && that.form.place_id.length<=1)						
        {
          that.limit_properties= 0 //没限制
          that.limit_place= 1 //限制1条
        }
        if(that.form.place_id.length>1 && that.form.properties_id.length<=1)
        {
          that.limit_properties= 1
          that.limit_place= 0
        }
       if(that.form.place_id.length==1 && that.form.properties_id.length==1)
       {
          that.limit_properties= 0
          that.limit_place= 0
       }
       //......
     },
   },
相关推荐
xingyuzhisuan1 天前
网络 Token 常见故障原理,基础排查科普
运维·服务器·网络·php
z落落1 天前
C#String字符串
开发语言·c#·php
fiveym1 天前
Debian 12 PXE 安装报错:Bad archive mirror 复合型故障排查全记录
运维·服务器·debian·php
STDD1 天前
strace 和 perf:Linux 进程调试和性能分析深度指南
linux·运维·php
mengqudoh1 天前
elementui el-table 表头固定功能
javascript·vue.js·elementui
上海合宙LuatOS1 天前
Air8000低功耗指南
开发语言·物联网·php·lua
ch_ziyuan1 天前
2026新优化神马TV8.5影视点播系统保姆级搭建教程:三后台配置+反编译修改
android·ios·php
難釋懷1 天前
Nginx高可用配置
linux·nginx·php
D4c-lovetrain2 天前
Jenkins自动化部署PHP项目
自动化·jenkins·php
zzqssliu2 天前
跨境独立站多端适配开发:多语言+多货币+跨平台同步技术实战
前端·javascript·php