2018-07-20 14:06:03 +08:00
---
2018-09-24 15:48:30 +08:00
title: Check
2019-01-29 16:31:24 +08:00
preview: https://didi.github.io/mand-mobile/examples/#/check
2018-07-20 14:06:03 +08:00
---
2018-12-10 15:41:29 +08:00
UI renderless check group component
2018-07-20 14:06:03 +08:00
### Import
```javascript
2018-11-19 22:41:04 +08:00
import { Check, CheckBox, CheckGroup, CheckList } from 'mand-mobile'
2018-07-20 14:06:03 +08:00
2018-11-19 22:41:04 +08:00
Vue.component(Check.name, Check)
Vue.component(CheckBox.name, CheckBox)
2018-07-20 14:06:03 +08:00
Vue.component(CheckGroup.name, CheckGroup)
2018-11-19 22:41:04 +08:00
Vue.component(CheckList.name, CheckList)
2018-07-20 14:06:03 +08:00
```
### Code Examples
<!-- DEMO -->
### API
2018-11-19 22:41:04 +08:00
#### Check Props
| Props | Description | Type | Default | Note |
|----|-----|------|------|------|
2019-01-29 20:12:21 +08:00
|name|unique name|any|`true`|-|
|v-model|selected name|any|`false`|-|
2019-02-19 11:03:40 +08:00
|label|option text|String|-|-|
2018-11-19 22:41:04 +08:00
|disabled|whether disable selection or not|Boolean|`false`|-|
2019-02-19 11:03:40 +08:00
|icon|icon name of checked options|String|`checked`|-|
|icon-inverse|icon name of unchecked options|String|`checke`|-|
|icon-disabled|icon name of disabled options|String|`check-disabled`|-|
2019-06-13 16:15:12 +08:00
|icon-svg< sup class = "version-after" > 2.3.0+< / sup > |use svg icon|Boolean|`false`|-|
|size|size of icon|String|`md`|-|
2019-09-11 17:06:46 +08:00
2018-11-19 22:41:04 +08:00
---
#### CheckBox Props
| Props | Description | Type | Default | Note |
|----|-----|------|------|------|
2019-01-29 20:12:21 +08:00
|name|unique name|any|`true`|-|
|v-model|selected name|any|`false`|-|
2018-11-19 22:41:04 +08:00
|disabled|whether disable selection or not|Boolean|`false`|-|
---
2018-07-20 14:06:03 +08:00
#### CheckGroup Props
2018-11-19 22:41:04 +08:00
Check multiple checks. Combine with `Check` or `CheckBox` .
| Props | Description | Type | Default | Note |
|----|-----|------|------|------|
|v-model|selected names|Array|-|-|
|max|max selected name length|Number|`0`|`0`: no limit|
2018-07-20 14:06:03 +08:00
#### CheckGroup Methods
2018-11-19 22:41:04 +08:00
##### check(name)
2018-07-20 14:06:03 +08:00
2018-11-19 22:41:04 +08:00
| Arg | Description | Type | Default |
2018-07-20 14:06:03 +08:00
|----|-----|------|------|
2018-11-19 22:41:04 +08:00
|name|name will be selected|String|-|
2018-07-20 14:06:03 +08:00
2018-11-19 22:41:04 +08:00
##### uncheck(name)
2018-07-20 14:06:03 +08:00
2018-11-19 22:41:04 +08:00
| Arg | Description | Type | Default |
|----|-----|------|------|
|name|name will be unselected|String|-|
##### toggle(name)
| Arg | Description | Type | Default |
|----|-----|------|------|
|name|name will be toggle|String|-|
2020-03-26 14:54:35 +08:00
##### toggleAll(checked?: Boolean)
Select All or Deselect (`disabled` options will not be changed) < sup class = "version-after" > 2.5.9+< / sup >
| Arg | Description | Type | Default |
|----|-----|------|------|
|checked|select all or none|Boolean|reverse election if empty|
2018-11-19 22:41:04 +08:00
---
#### CheckList Props
2018-12-03 19:20:00 +08:00
| Arg | Description | Type | Default | Note |
2018-11-19 22:41:04 +08:00
|----|-----|------|------|------|
2018-12-03 19:20:00 +08:00
|v-model|selected names|Array|-|-|
2018-11-19 22:41:04 +08:00
|options|data otpions|Array< {text, value, disabled, ...}>|`[]`|-|
2019-06-13 16:15:12 +08:00
|icon< sup class = "version-after" > 2.3.0+< / sup > |icon of selected option|String|`checked`|-|
|icon-inverse< sup class = "version-after" > 2.3.0+< / sup > |icon of unselected options|String|`check`|-|
|icon-disabled< sup class = "version-after" > 2.3.0+< / sup > |icon of disabled options|String|`check-disabled`|-|
|icon-size< sup class = "version-after" > 2.3.0+< / sup > |the size of icon|String|`md`|-|
|icon-svg< sup class = "version-after" > 2.3.0+< / sup > |use svg icon|Boolean|`false`|-|
|icon-position< sup class = "version-after" > 2.3.0+</ sup > |the position of icon|String|`right`|`left`, `right` |
2018-12-03 19:20:00 +08:00
|is-slot-scope|if it is mandatory to use `slot-scope` |Boolean|-|it depends on exact cases to determine whether to use it or not, and avoids adding `if/else` to component|
2018-11-19 22:41:04 +08:00
#### CheckList Slots
`CheckGroup` default slot will be used as template, and it will receive `{option}` from `slot-scope` .
```html
< template >
< md-check-list :options = "data" >
2019-09-24 17:35:27 +08:00
< template slot-scope = "{ option, index, selected }" >
2018-11-19 22:41:04 +08:00
< div class = "custom-title" v-text = "option.text" > < / div >
< div class = "custom-brief" > {{ option.text }} custom description< / div >
< / template >
< / md-check-list >
< / template >
2018-07-20 14:06:03 +08:00
```