CheckList 复选列表

Scan me!

复选列表. 1.5.0+

引入

  1. import { CheckList } from 'mand-mobile'
  2. Vue.component(CheckList.name, CheckList)

代码演示

复选框

  1. <template>
  2. <div class="md-example-child md-example-child-single-component">
  3. <md-check-list
  4. v-model="checked"
  5. :options="options"
  6. ></md-check-list>
  7. </div>
  8. </template>
  9. <script>
  10. import {CheckList} from 'mand-mobile'
  11. export default {
  12. name: 'checkbox-demo',
  13. title: '复选框',
  14. components: {
  15. [CheckList.name]: CheckList,
  16. },
  17. data() {
  18. return {
  19. checked: '1',
  20. options: [
  21. {value: '1', label: '选项一', disabled: false},
  22. {value: '2', label: '选项二', disabled: false},
  23. {value: '3', label: '选项三', disabled: false},
  24. {value: '4', label: '选项四', disabled: true},
  25. {value: '5', label: '选项五', disabled: false},
  26. {value: '6', label: '选项六', disabled: false},
  27. ],
  28. }
  29. },
  30. }
  31. </script>
  32. <style lang="stylus" scoped>
  33. </style>
  34.  

自定义内容模板

  1. <template>
  2. <div class="md-example-child md-example-child-single-component">
  3. <md-check-list
  4. title="至多选3个"
  5. v-model="checked"
  6. :options="options"
  7. :max="3"
  8. iconPosition="left"
  9. icon="circle-right"
  10. iconInverse="circle"
  11. iconSize="md"
  12. >
  13. <div slot="content" slot-scope="{ option }">
  14. <p v-text="option.label"></p>
  15. <p class="muted" v-text="option.desc"></p>
  16. </div>
  17. </md-check-list>
  18. </div>
  19. </template>
  20. <script>
  21. import {CheckList} from 'mand-mobile'
  22. export default {
  23. name: 'checkbox-demo',
  24. title: '自定义内容模板',
  25. components: {
  26. [CheckList.name]: CheckList,
  27. },
  28. data() {
  29. return {
  30. checked: [],
  31. options: [
  32. {value: '1', label: '选项一', desc: '描述文字字段可根据具体场景更改', disabled: false},
  33. {value: '2', label: '选项二', desc: '描述文字字段可根据具体场景更改', disabled: false},
  34. {value: '3', label: '选项三', desc: '描述文字字段可根据具体场景更改', disabled: false},
  35. {value: '4', label: '选项四', desc: '描述文字字段可根据具体场景更改', disabled: true},
  36. {value: '5', label: '选项五', desc: '描述文字字段可根据具体场景更改', disabled: false},
  37. {value: '6', label: '选项六', desc: '描述文字字段可根据具体场景更改', disabled: false},
  38. ],
  39. }
  40. },
  41. }
  42. </script>
  43. <style lang="stylus" scoped>
  44. .muted
  45. color #888
  46. font-size 80%
  47. </style>
  48.  

API

CheckList Props

属性说明类型默认值备注
v-model选中的值[String,Array]-若为单选则用String, 若为多选则是Array
options选择项数组Array--
max最多选择几项Number1为1为单选,为0不限制数量,大于1则是限制至多选择数量
disabled是否禁用选择Booleanfalse-
title标题String''-
icon选中图标String'right'-
iconPosition图标位置String'right'-
iconSize图标尺寸String'sm'-
options

选择项数组格式如下,其中value值必填, 其余为选填, 可添加自定义字段。

  1. [
  2. { value: '', disabled: false }
  3. ]

CheckList Methods

select(value)
参数说明类型默认值
value即将新增的选中选项值[String, Array]-