File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ Component({
9191 * 组件的初始数据
9292 */
9393 data : {
94+ // segment-item 绑定的 data-cell 数据
95+ _cells :[ ] ,
9496 tabList : [ ] ,
9597 currentIndex : 0 ,
9698 _segmentItemInstances : [ ]
@@ -107,16 +109,20 @@ Component({
107109 if ( items . length === this . data . tabList . length && this . data . _segmentItemInstances . indexOf ( segmentItemInstance ) > 0 ) return ;
108110 let activeKey = val ,
109111 currentIndex = this . data . currentIndex ;
112+ let _cells = [ ] ;
110113 const tab = items . map ( ( item , index ) => {
111114 activeKey = ! val && index === 0 ? item . data . key : activeKey ;
112115 currentIndex = item . data . key === activeKey ? index : currentIndex ;
116+ // 存储 segment-item 绑定的 data-cell 数据
117+ _cells [ index ] = item . dataset . cell ;
113118 return {
114119 ...item . data
115120 } ;
116121 } ) ;
117122 this . setData ( {
118- tabList : tab ,
123+ _cells ,
119124 activeKey,
125+ tabList : tab ,
120126 currentIndex,
121127 _segmentItemInstances : items
122128 } , ( ) => {
@@ -150,7 +156,8 @@ Component({
150156 } ) ;
151157 this . triggerEvent ( 'linchange' , {
152158 activeKey,
153- currentIndex
159+ currentIndex,
160+ cell :this . data . _cells [ currentIndex ]
154161 } ) ;
155162 }
156163 }
You can’t perform that action at this time.
0 commit comments