index.vue
2.15 KB
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
76
77
78
79
80
81
82
83
84
<template>
<div class="container">
<div class="doc-title zan-hairline--bottom">SELECT</div>
<div class="zan-panel-title">基础用法</div>
<div class="zan-panel">
<div>
<zan-select v-bind="{ items, checkedValue: checked.base, componentId: 'base'}" @handleZanSelectChange="handleZanSelectChange"/>
</div>
</div>
<div class="zan-panel-title">自定义高亮颜色</div>
<div class="zan-panel">
<div>
<zan-select v-bind="{ items, checkedValue: checked.color, activeColor, componentId: 'color'}" @handleZanSelectChange="handleZanSelectChange"/>
</div>
</div>
<div class="zan-panel-title">Form 表单中的select应用</div>
<form @submit="formSubmit">
<div class="zan-panel">
<div>
<zan-select v-bind="{ items, checkedValue: checked.form, name: 'formtest', componentId: 'form'}" @handleZanSelectChange="handleZanSelectChange"/>
</div>
</div>
<div class="zan-btns">
<button
class="zan-btn zan-btn--primary"
formType="submit">提交数据</button>
</div>
</form>
<toptips />
</div>
</template>
<script>
import { getComponentByTag } from '../../utils/helper'
import ZanSelect from '../../components/zan/select'
import ZanTopTips from '../../components/zan/toptips'
export default {
components: {
ZanSelect,
toptips: ZanTopTips
},
data () {
return {
items: [
{
padding: 0,
value: '1',
name: '选项一'
},
{
padding: 0,
value: '2',
name: '选项二'
}
],
checked: {
base: '-1',
color: '-1',
form: '-1'
},
activeColor: '#4b0'
}
},
methods: {
handleZanSelectChange ({ componentId, value }) {
this.checked[componentId] = value
},
formSubmit (event) {
console.log('[zan:field:submit]', event.target.value)
getComponentByTag(this, 'toptips').showZanTopTips(`选中的值为${event.target.value.formtest}`)
}
}
}
</script>
<style scoped>
</style>