File tree 3 files changed +27
-3
lines changed
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ export default {
12
12
{
13
13
id: 'city',
14
14
type: 'checkbox-group',
15
+ /**
16
+ * sytle 属性是为了满足 el-checkbox-button属性而设置,如果不需要使用el-radio-button这可不设置
17
+ */
18
+ style: 'button',
15
19
label: 'city',
16
20
default: ['new york'],
17
21
options: [
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ export default {
13
13
id: 'city',
14
14
type: 'radio-group',
15
15
label: 'city',
16
+ /**
17
+ * sytle 属性是为了满足 el-radio-button属性而设置,如果不需要使用el-radio-button这可不设置
18
+ */
19
+ style: 'button',
16
20
default: 'new york',
17
21
options: [
18
22
/**
Original file line number Diff line number Diff line change 45
45
:key =" optionKey(opt) || index"
46
46
v-bind =" opt"
47
47
/>
48
- <!-- TODO: 支持 el-checkbox-button 变体 -->
48
+ <el-checkbox-button
49
+ v-else-if =" data.type === 'checkbox-group' && data.style === 'button'"
50
+ :key =" opt.value"
51
+ v-bind =" opt"
52
+ :label =" 'value' in opt ? opt.value : opt.label"
53
+ >
54
+ {{ opt.label }}
55
+ </el-checkbox-button >
56
+
49
57
<el-checkbox
50
- v-else-if =" data.type === 'checkbox-group'"
58
+ v-else-if =" data.type === 'checkbox-group' && data.style !== 'button' "
51
59
:key =" opt.value"
52
60
v-bind =" opt"
53
61
:label =" 'value' in opt ? opt.value : opt.label"
56
64
</el-checkbox >
57
65
<!-- WARNING: radio 用 label 属性来表示 value 的含义 -->
58
66
<!-- FYI: radio 的 value 属性可以在没有 radio-group 时用来关联到同一个 v-model -->
67
+ <el-radio-button
68
+ v-else-if =" data.type === 'radio-group' && data.style === 'button'"
69
+ :key =" opt.label"
70
+ v-bind =" opt"
71
+ :label =" 'value' in opt ? opt.value : opt.label"
72
+ >{{ opt.label }}</el-radio-button
73
+ >
74
+
59
75
<el-radio
60
- v-else-if =" data.type === 'radio-group'"
76
+ v-else-if =" data.type === 'radio-group' && data.style !== 'button' "
61
77
:key =" opt.label"
62
78
v-bind =" opt"
63
79
:label =" 'value' in opt ? opt.value : opt.label"
You can’t perform that action at this time.
0 commit comments