zoukankan      html  css  js  c++  java
  • 多选

      div()
        div()
          p 选择平台
            el-form-item()
              el-checkbox( label="全部", :indeterminate="isIndeterminate", v-model="checkAll", @change="handleCheckAllChange")
          div()
            el-form-item
                                      el-checkbox-group( v-model="popupform.receivers", @change="handleCheckedCitiesChange")
                                            el-checkbox( v-for="city in cities", :label="city.id", :key="city.id") {{city.name}}
     
     
      return {
                cities: [],
                checkAll: false,
                isIndeterminate: true,

                popupform: {
         receivers: [],
        }
      }
      
     mounted() {
            this.getDataList();
        },
        methods: {
            handleCheckAllChange(val) {
                // const _receivers = val ? this.cities.map(key => key.id) : [];
                // this.$set(this.popupform, 'receivers', _receivers)
        //绑定的值为 id ,则 this.cities.map(key => key.id)  为 id 
                this.popupform.receivers = val ? this.cities.map(key => key.id) : [];
                console.log(this.cities.map(key => key.id))
                this.isIndeterminate = false;
            },
            handleCheckedCitiesChange(value) {
       // value 是 :label="city.id" 绑定的值
                const checkedCount = value.length;
                this.checkAll = checkedCount === this.cities.length;
                this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
            },
            async getDataList() {
        //请求数据
                const result = await api.accountRangeList();
                this.cities = result.sellerTypeList;
            }
     }
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    多线程中,上锁的理解
    sql server 2008 联机丛书
    序列化是线程安全的么
    对象化下的编程——字段
    Dic实现工厂模式
    design principle:java 回调与委派/委托机制(转)
    风筝数据结构学习笔记(2)后序遍历二叉树(非递归)
    风筝数据结构学习笔记(1)利用链式存储结构和递归构建二叉树
    吕震宇老师《设计模式系列》
    吕震宇老师《设计模式随笔系列》
  • 原文地址:https://www.cnblogs.com/J-Luck/p/13361522.html
Copyright © 2011-2022 走看看