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
       }
       //......
     },
   },
相关推荐
360智汇云3 小时前
一次Redis超时引发的“冤案“
数据库·redis·php
ljs6482739514 小时前
Linux 网络常用命令与端口基础详解
linux·网络·php
m0_738120721 天前
PHP代码审计基础——超全局变量(三)
开发语言·安全·网络安全·php
m0_738120721 天前
PHP代码审计基础——面向对象(四)
android·开发语言·网络·安全·github·php
2601_963771371 天前
10 Best PHP Media CMS and Scripts for Web Creators in 2026
开发语言·前端·php
着迷不白1 天前
Linux系统故障修复、日志管理与安全加固实战指南
开发语言·php
Bobolink_2 天前
跨境业务网络环境评估,“干净、一致、独享”三个关键指标
开发语言·网络·php·跨境网络·网络环境
2401_894915532 天前
Geo搜索优化排名源码部署搭建全流程详解
android·开发语言·flask·php·精选
2601_963771372 天前
Hardening Enterprise WordPress Sites Against REST API Leaks and Bad Headers
前端·windows·word·php
weixin_BYSJ19872 天前
springboot美食食谱小程序---附源码24044
java·spring boot·python·spring cloud·django·tomcat·php