|
4 | 4 | <view class="uni-common-mt"> |
5 | 5 | <view class="uni-form-item uni-column"> |
6 | 6 | <view class="title">表单组件在label内</view> |
7 | | - <view class="uni-list"> |
8 | | - <checkbox-group @change="checkboxChange"> |
9 | | - <label class="uni-list-cell uni-list-cell-pd" v-for="item in checkboxItems" :key="item.name"> |
10 | | - <view> |
11 | | - <checkbox :value="item.name" :checked="item.checked"></checkbox> |
12 | | - </view> |
13 | | - <view>{{item.value}}</view> |
14 | | - </label> |
15 | | - </checkbox-group> |
16 | | - </view> |
| 7 | + <checkbox-group class="uni-list" @change="checkboxChange"> |
| 8 | + <label class="uni-list-cell uni-list-cell-pd" v-for="item in checkboxItems" :key="item.name"> |
| 9 | + <view> |
| 10 | + <checkbox :value="item.name" :checked="item.checked"></checkbox> |
| 11 | + </view> |
| 12 | + <view>{{item.value}}</view> |
| 13 | + </label> |
| 14 | + </checkbox-group> |
17 | 15 | </view> |
18 | | - |
| 16 | + |
19 | 17 | <view class="uni-form-item uni-column"> |
20 | 18 | <view class="title">label用for标识表单组件</view> |
21 | | - <view class="uni-list"> |
22 | | - <radio-group @change="radioChange"> |
23 | | - <label class="uni-list-cell uni-list-cell-pd" v-for="(item,index) in radioItems" :key="index"> |
24 | | - <view> |
25 | | - <radio :id="item.name" :value="item.name" :checked="item.checked"></radio> |
26 | | - </view> |
27 | | - <view> |
28 | | - <label class="label-2-text" :for="item.name"> |
29 | | - <text>{{item.value}}</text> |
30 | | - </label> |
31 | | - </view> |
32 | | - </label> |
33 | | - </radio-group> |
34 | | - </view> |
35 | | - |
| 19 | + <radio-group class="uni-list" @change="radioChange"> |
| 20 | + <label class="uni-list-cell uni-list-cell-pd" v-for="(item,index) in radioItems" :key="index"> |
| 21 | + <view> |
| 22 | + <radio :id="item.name" :value="item.name" :checked="item.checked"></radio> |
| 23 | + </view> |
| 24 | + <view> |
| 25 | + <label class="label-2-text" :for="item.name"> |
| 26 | + <text>{{item.value}}</text> |
| 27 | + </label> |
| 28 | + </view> |
| 29 | + </label> |
| 30 | + </radio-group> |
36 | 31 | </view> |
37 | 32 |
|
38 | 33 | <view class="uni-form-item uni-column"> |
39 | 34 | <view class="title">label内有多个时选中第一个</view> |
40 | | - <view class="uni-list"> |
41 | | - <checkbox-group @change="checkboxChange"> |
42 | | - <label class="label-3"> |
43 | | - <view class="uni-list-cell uni-list-cell-pd"> |
44 | | - <checkbox class="checkbox-3">选项一</checkbox> |
45 | | - </view> |
46 | | - <view class="uni-list-cell uni-list-cell-pd"> |
47 | | - <checkbox class="checkbox-3">选项二</checkbox> |
48 | | - </view> |
49 | | - <view class="uni-link uni-center" style="margin-top:20upx;">点击该label下的文字默认选中第一个checkbox</view> |
50 | | - </label> |
51 | | - </checkbox-group> |
52 | | - </view> |
| 35 | + <checkbox-group class="uni-list" @change="checkboxChange"> |
| 36 | + <label class="label-3"> |
| 37 | + <view class="uni-list-cell uni-list-cell-pd"> |
| 38 | + <checkbox class="checkbox-3">选项一</checkbox> |
| 39 | + </view> |
| 40 | + <view class="uni-list-cell uni-list-cell-pd"> |
| 41 | + <checkbox class="checkbox-3">选项二</checkbox> |
| 42 | + </view> |
| 43 | + <view class="uni-link uni-center" style="margin-top:20upx;">点击该label下的文字默认选中第一个checkbox</view> |
| 44 | + </label> |
| 45 | + </checkbox-group> |
53 | 46 | </view> |
54 | 47 |
|
55 | 48 | </view> |
|
84 | 77 | } |
85 | 78 | }, |
86 | 79 | methods: { |
87 | | - checkboxChange: function (e) { |
| 80 | + checkboxChange: function(e) { |
| 81 | + console.log(e) |
88 | 82 | var checked = e.target.value |
89 | 83 | var changed = {} |
90 | 84 | for (var i = 0; i < this.checkboxItems.length; i++) { |
|
95 | 89 | } |
96 | 90 | } |
97 | 91 | }, |
98 | | - radioChange: function (e) { |
| 92 | + radioChange: function(e) { |
99 | 93 | var checked = e.target.value |
100 | 94 | var changed = {} |
101 | 95 | for (var i = 0; i < this.radioItems.length; i++) { |
|
106 | 100 | } |
107 | 101 | } |
108 | 102 | }, |
109 | | - tapEvent: function (e) { |
| 103 | + tapEvent: function(e) { |
110 | 104 | console.log('按钮被点击') |
111 | 105 | } |
112 | 106 | } |
113 | 107 | } |
114 | 108 | </script> |
115 | 109 |
|
116 | 110 | <style> |
117 | | -.uni-list-cell { |
118 | | - justify-content: flex-start |
119 | | -} |
120 | | -</style> |
| 111 | + .uni-list-cell { |
| 112 | + justify-content: flex-start |
| 113 | + } |
| 114 | +
|
| 115 | + .uni-list .label-3 { |
| 116 | + padding: 0; |
| 117 | + } |
| 118 | +</style> |
0 commit comments