File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ Component({
91
91
* 组件的初始数据
92
92
*/
93
93
data : {
94
+ // segment-item 绑定的 data-cell 数据
95
+ _cells :[ ] ,
94
96
tabList : [ ] ,
95
97
currentIndex : 0 ,
96
98
_segmentItemInstances : [ ]
@@ -107,16 +109,20 @@ Component({
107
109
if ( items . length === this . data . tabList . length && this . data . _segmentItemInstances . indexOf ( segmentItemInstance ) > 0 ) return ;
108
110
let activeKey = val ,
109
111
currentIndex = this . data . currentIndex ;
112
+ let _cells = [ ] ;
110
113
const tab = items . map ( ( item , index ) => {
111
114
activeKey = ! val && index === 0 ? item . data . key : activeKey ;
112
115
currentIndex = item . data . key === activeKey ? index : currentIndex ;
116
+ // 存储 segment-item 绑定的 data-cell 数据
117
+ _cells [ index ] = item . dataset . cell ;
113
118
return {
114
119
...item . data
115
120
} ;
116
121
} ) ;
117
122
this . setData ( {
118
- tabList : tab ,
123
+ _cells ,
119
124
activeKey,
125
+ tabList : tab ,
120
126
currentIndex,
121
127
_segmentItemInstances : items
122
128
} , ( ) => {
@@ -150,7 +156,8 @@ Component({
150
156
} ) ;
151
157
this . triggerEvent ( 'linchange' , {
152
158
activeKey,
153
- currentIndex
159
+ currentIndex,
160
+ cell :this . data . _cells [ currentIndex ]
154
161
} ) ;
155
162
}
156
163
}
You can’t perform that action at this time.
0 commit comments