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
       }
       //......
     },
   },
相关推荐
catchadmin1 天前
Laravel12 + Vue3 的免费可商用商业级管理后台 CatchAdmin V5 正式发布
开发语言·php
亚历山大海1 天前
PHPword支持导出富文本网络图片,支持SVG导出
php
小李独爱秋1 天前
计算机网络经典问题透视:TLS协议工作过程全景解析
运维·服务器·开发语言·网络协议·计算机网络·php
易营宝1 天前
高效的跨境电商广告优化系统:易营宝广告投放实操指南
大数据·开发语言·人工智能·php
运维行者_1 天前
远程办公场景 NFA:从网络嗅探与局域网流量监控软件排查团队网络卡顿问题
运维·服务器·开发语言·网络·自动化·php
掘根2 天前
【仿Muduo库项目】HTTP模块4——HttpServer子模块
网络协议·http·php
郑州光合科技余经理2 天前
私有化B2B订货系统实战:核心模块设计与代码实现
java·大数据·开发语言·后端·架构·前端框架·php
Aotman_2 天前
Vue el-table 字段自定义排序(进阶)
前端·javascript·vue.js·elementui·前端框架·ecmascript
万岳软件开发小城2 天前
直播电商系统源码搭建直播带货APP/小程序的完整流程
小程序·php·软件开发·直播带货系统源码·直播电商app开发
凡大来啦2 天前
Element plus的Select选择器点击不出现下拉列表
javascript·vue.js·elementui