element實現選擇器,全選功能


首先增加全選按鈕:

<el-select filterable v-model="cityIds" multiple  collapse-tags   placeholder="請選擇"  @change="getCityNames" >
           <el-option label="----全選----" value="000"></el-option>
          <el-option v-for="item in options.cityList" 
                        :key="item.area_id" 
                        :label="item.area_name"
                        :value="item.area_id">
           </el-option>
</el-select>

通過watch事件進行,全選互斥:

watch: {
            cityIds:function(value){
                let valength = value.length;
                if(valength > 1 && value[valength - 1] == "000"){
                    this.cityIds = ["000"];
                }else if(valength == 2 && value[0] == "000"){
                    this.cityIds.shift();
                }
            }
        },

最后再通過change事件進行數據處理,ok

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM