# Checkbox (checkbox)
# Description
Allows users to select multiple items in a form.
# Usage result
# How to use it
Importing a component in a .ux file:
<import name="q-checkbox" src="qaui/src/components/checkbox/index"></import>
1
# Example
<template>
<div class="qaui-wrap">
<q-checkbox-group
id="myGroup"
current="{{current}}"
onchange="handleChange"
>
<q-checkbox
group="myGroup"
type="list"
for="{{list}}"
value="{{$item.value}}"
checked="{{$item.checked}}"
disabled="{{$item.disabled}}"
></q-checkbox>
</q-checkbox-group>
</div>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export default {
data() {
return {
list: [
{
id: 1,
value: 'Option 1',
checked: true,
},
{
id: 2,
value: 'Option 2',
checked: true,
disabled: true,
},
{
id: 3,
value: 'Option 3',
},
{
id: 4,
value: 'Option 4',
disabled: true,
},
],
current: ['Option 2', 'Option 1'],
}
},
handleChange({ detail }) {
const index = this.current.indexOf(detail.value)
index === -1
? this.current.push(detail.value)
: this.current.splice(index, 1)
},
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
.qaui-wrap {
flex-direction: column;
align-items: center;
background-color: #f2f2f2;
padding: 10px 0;
}
1
2
3
4
5
6
2
3
4
5
6
# API
# Component Properties
| Attribute | Type | Value by default | Description |
|---|---|---|---|
checked | Boolean | false | Whether it is selected or not |
disabled | Boolean | false | Disabled |
value | String | - | The value of the option |
group | String | - | The id of the group to which the checkbox belongs |
# Component Events
| Event name | Event description | Value returned |
|---|---|---|
change | Change of value | {current:current, value:value} |