复选框 Checkbox

基本

  1. <za-cell>
  2. <za-checkbox @change="handleChange">普通</za-checkbox>
  3. </za-cell>
  4. <za-cell>
  5. <za-checkbox checked @change="handleChange">选中</za-checkbox>
  6. </za-cell>
  7. <za-cell>
  8. <za-checkbox disabled>禁止</za-checkbox>
  9. </za-cell>
  10. <za-cell>
  11. <za-checkbox checked disabled>选中且禁止</za-checkbox>
  12. </za-cell>

单列样式

  1. <za-checkbox v-model="v5" @change="handleChange" type="cell">阅读并同意《XXX条款》中的相关规定</za-checkbox>

按钮样式

  1. <za-cell>
  2. <za-checkbox-group v-model="checkboxGroup2" slot="description" type="button" @change="handleGroupChange">
  3. <za-checkbox v-for="(city, index) in cities" :value="city" :key="city"></za-checkbox>
  4. </za-checkbox-group>
  5. 普通
  6. </za-cell>
  7. <za-cell>
  8. <za-checkbox-group v-model="checkboxGroup3" slot="description" type="button" @change="handleGroupChange">
  9. <za-checkbox v-for="city in cities" :value="city" :key="city"></za-checkbox>
  10. </za-checkbox-group>
  11. 指定默认值
  12. </za-cell>
  13. <za-cell>
  14. <za-checkbox-group v-model="checkboxGroup4" slot="description" type="button" @change="handleGroupChange">
  15. <za-checkbox v-for="(city, index) in cities" :value="city" :key="city" :disabled="index === 2"></za-checkbox>
  16. </za-checkbox-group>
  17. 禁用指定项
  18. </za-cell>
  19. <za-cell>
  20. <za-checkbox-group v-model="checkboxGroup5" slot="description" type="button" shape="rect" @change="handleGroupChange">
  21. <za-checkbox v-for="(city, index) in cities" :value="city" :key="city"></za-checkbox>
  22. </za-checkbox-group>
  23. 直角
  24. </za-cell>
  25. <za-cell>
  26. <za-checkbox-group v-model="checkboxGroup6" slot="description" type="button" shape="round" @change="handleGroupChange">
  27. <za-checkbox v-for="(city, index) in cities" :value="city" :key="city"></za-checkbox>
  28. </za-checkbox-group>
  29. 椭圆角
  30. </za-cell>

块级样式

  1. <div style="padding:10px;">
  2. <za-checkbox-group v-model="provice" type="button" block shape="radius" @change="handleGroupChange">
  3. <za-checkbox v-for="(city, index) in cities" :value="city" :key="city"></za-checkbox>
  4. </za-checkbox-group>
  5. </div>

列表组样式

<za-checkbox-group v-model="checkboxGroup7" type="cell" @change="handleGroupChange">
  <za-checkbox v-for="(city, index) in cities" :value="city" :key="city" :disabled="index === 2"></za-checkbox>
</za-checkbox-group>

列表样式禁用状态

<za-checkbox-group v-model="checkboxGroup8" type="cell" disabled @change="handleGroupChange">
  <za-checkbox v-for="(city, index) in cities" :value="city" :key="city"></za-checkbox>
</za-checkbox-group>

Vue Script

<script name="vue">
export default {
  data() {
    return {
      v1: false,
      v2: true,
      v3: false,
      v4: true,
      v5: false,
      city: null,
      cities: ['上海', '北京', '广州', '深圳'],
      provice: [],
      provices: [{
        label: '条件A',
        checked: false,
        checkeds: []
      },{
        label: '条件B',
        checked: false,
        checkeds: []
      },{
        label: '条件C',
        checked: false,
        checkeds: []
      }],
      checkboxGroup: ['上海'],
      checkboxGroup2: [],
      checkboxGroup3: ['上海', '北京'],
      checkboxGroup4: [],
      checkboxGroup5: [],
      checkboxGroup6: [],
      checkboxGroup7: [],
      checkboxGroup8: [],
    }
  },
  methods: {
    handleChange(v, e) {
      console.log(v, e);
    },
    handleGroupChange(v, e){
      console.log(v, e);
    },
  },
};
</script>

API

Checkbox-Group Attributes

属性类型默认值可选值/参数说明
themestring'primary''default', 'primary', 'info', 'success', 'warning', 'error'主题
shapestring'radius', 'round'形状
typestring'button', 'cell'显示类型
v-modelarray[ ]绑定变量
blockbooleanfalse是否为块级元素
disabledbooleanfalse是否禁用

Checkbox Attributes

属性类型默认值可选值/参数说明
themestring'primary''default', 'primary', 'info', 'success', 'warning', 'error'主题
typestring'button', 'cell'显示类型
valuestring,number选项值
checkedboolean是否选中
disabledbooleanfalse是否禁用

Checkbox Group Events

事件名称说明回调参数
change当绑定值变化时触发的事件1.选中的值列表,2.event 事件对象

Checkbox Events

事件名称说明回调参数
change当绑定值变化时触发的事件1.选中的值列表,2.event 事件对象

Checkbox 复选框 - 图1