微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

elementUI多选框获取值

elementUI种的多选框和单选框差不多,
(1)el-checkBox-group里绑定一个数组
(2)el-checkBox-group绑定一个方法获取
(3)for循环选项,绑定key,label
(4)el-checkBox里还可以绑定disabled和checked
例子:

 

<template>
  <div>
    <el-checkBox-group v-model="test" @change="getValue()">
      <el-checkBox  v-for="(item,i) in items" :key="i" :label="item.content" :disabled="item.disabled" :checked="item.checked"></el-checkBox>
    </el-checkBox-group>
  </div>
</template>
<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      test:[], // 认选项,要在el-checkBox-group里绑定一个空数组
      items:[
        {id:0,content:"选项一",disabled:false,checked:true},
        {id:1,content:"选项二",disabled:true,checked:false},
        {id:2,content:"选项三",disabled:false,checked:false},
      ]
    };
  },
  methods: {
    getValue(){
      console.log(this.test)
    }
  },
};
</script>
<style lang="css" scoped>
</style>

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐