码迷,mamicode.com
首页 > 其他好文 > 详细

elementUI多选框获取值

时间:2019-10-05 22:16:19      阅读:893      评论:0      收藏:0      [点我收藏+]

标签:check   style   class   hang   turn   console   hello   efault   methods   

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>

 

elementUI多选框获取值

标签:check   style   class   hang   turn   console   hello   efault   methods   

原文地址:https://www.cnblogs.com/luguankun/p/11625897.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!