ce4c83ff
wxy
初始提交
|
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
|
<template>
<div class="container">
<div class="doc-title zan-hairline--bottom">SWITCH</div>
<div class="zan-panel-title">同步开关</div>
<div class="zan-panel">
<ZanSwitch v-bind="sync" :componentId="'sync'" />
</div>
<div class="zan-panel-title">异步开关</div>
<div class="zan-panel">
<ZanSwitch v-bind="async" :componentId="'async'" />
</div>
<div class="zan-panel-title">开关不可用</div>
<div class="zan-panel">
<ZanSwitch v-bind="{ checked: false, disabled: true, componentId: 'switch3', styles: 'margin-right: 8px;' }" />
<ZanSwitch v-bind="{ checked: true, disabled: true, componentId: 'switch4' }" />
</div>
</div>
</template>
<script>
import ZanSwitch from '../../components/zan/switch'
export default {
components: {
ZanSwitch
},
data () {
return {
sync: {
checked: false,
handleZanSwitchChange: this.handleZanSwitchChange
},
async: {
checked: true,
loading: false,
handleZanSwitchChange: this.handleZanSwitchChange
}
}
},
methods: {
handleZanSwitchChange (e) {
console.log(this)
const componentId = e.componentId
const checked = e.checked
if (componentId === 'sync') {
// 同步开关
this[componentId].checked = checked
} else if (componentId === 'async') {
// 异步开关
this[componentId].loading = true
setTimeout(() => {
this[componentId].loading = false
this[componentId].checked = checked
}, 500)
}
}
}
}
</script>
<style scoped >
.zan-panel {
padding: 10px;
}
/*.zan-switch {*/
/*margin-right: 8px;*/
/*}*/
</style>
|