背景
默认的el-select可以实现多选,模糊查询等功能,但是没有全选按钮,话不多说,咱们加一个。
html部分
全选
data定义
checkbox: {}
js部分
selectAll(item, index) { //我这里是针对循环的多个下拉框增加多选。如果是单个,直接判断v-model绑定的值即可。 if (this.checkbox[item.col_name]) { item.datas.forEach(item1 => { //按照自己的需求push就可以啦。 this.search[item.col_name].push(item1.value); }); } else { this.search[item.col_name] = []; } }
效果
![b85b1de2797400792867ce7a3cb8909c.png](https://i-blog.csdnimg.cn/blog_migrate/4850eedde35ee8238d81bab763858506.jpeg)
搞定,奥利给了兄弟们