forked from hminghe/weex-amui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.vue
executable file
·75 lines (73 loc) · 2.03 KB
/
index.vue
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<template>
<div>
<am-nav-bar title="am-list-redio"></am-nav-bar>
<scroller class="scroller">
<div>
<am-list header="单选" :footer="`value=${value}`">
<am-list-radio
v-for="item in list"
:key="item.value"
:title="item.name"
:checked="item.value === value"
@change="value = item.value"
></am-list-radio>
<am-list-radio
title="自定义颜色(color=red)"
color="red"
:checked="value === 5"
@change="value = 5"
></am-list-radio>
<am-list-radio
title="标题"
brief="说明一下"
align="top"
:checked="value === 6"
@change="value = 6"
></am-list-radio>
<am-list-radio
title="禁用(不能点击)"
brief="value=1"
:checked="value === 1"
@change="value = 1"
:disabled="true"
></am-list-radio>
</am-list>
<am-list header="其实也可以把他变成多选" :footer="'value=' + JSON.stringify(value2)">
<am-list-radio
v-for="item in list"
:key="item.value"
:title="item.name"
:checked="value2.indexOf(item.value) > -1"
@change="handleChange(item)"
></am-list-radio>
</am-list>
</div>
</scroller>
</div>
</template>
<script>
import { AmNavBar, AmList, AmListRadio } from '../../index'
export default {
components: { AmNavBar, AmList, AmListRadio },
data () {
return {
value: 0,
value2: [1],
list: Array.from(new Array(3)).map((v, k) => ({
value: k,
name: `Radio ${k}`
}))
}
},
methods: {
handleChange (item) {
let index = this.value2.indexOf(item.value)
if (index > -1) {
this.value2.splice(index, 1)
} else {
this.value2.push(item.value)
}
}
}
}
</script>