File tree Expand file tree Collapse file tree 3 files changed +54
-5
lines changed Expand file tree Collapse file tree 3 files changed +54
-5
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,36 @@ export default class PickerItem extends SuperComponent {
9191 } ) ;
9292 } ) ;
9393 } ,
94+ onTap ( e ) {
95+ const { index } = e . currentTarget . dataset ;
96+ const {
97+ itemHeight,
98+ data : { options, classPrefix } ,
99+ } = this ;
100+ wx . createSelectorQuery ( )
101+ . in ( this )
102+ . select ( `#${ classPrefix } __group` )
103+ . node ( )
104+ . exec ( ( res ) => {
105+ const scrollView = res [ 0 ] . node ;
106+ scrollView . scrollTo ( {
107+ top : 0 ,
108+ } ) ;
109+ } ) ;
110+ this . setData ( {
111+ duration : DefaultDuration ,
112+ offset : - index * itemHeight ,
113+ } ) ;
114+ wx . nextTick ( ( ) => {
115+ this . _selectedIndex = index ;
116+ this . _selectedValue = options [ index ] ?. value ;
117+ this . _selectedLabel = options [ index ] ?. label ;
118+ this . parent ?. triggerColumnChange ( {
119+ index,
120+ column : this . columnIndex || 0 ,
121+ } ) ;
122+ } ) ;
123+ } ,
94124
95125 // 刷新选中状态
96126 update ( ) {
Original file line number Diff line number Diff line change 11<wxs src="../common/utils.wxs" module="_" />
22<view
3+ id="{{classPrefix}}__group"
34 style="{{ style }}"
45 class="{{_.cls(classPrefix + '__group', [])}} class {{prefix}}-class"
6+ enhanced="true"
57 bind:touchstart="onTouchStart"
68 catch:touchmove="onTouchMove"
79 bind:touchend="onTouchEnd"
1719 wx:key="index"
1820 wx:for-item="option"
1921 data-index="{{ index }}"
22+ bind:tap="onTap"
2023 >
2124 {{option.label}}
2225 </view>
2326 </view>
24- </view>
27+ </scroll- view>
Original file line number Diff line number Diff line change 11<wxs src="../common/utils.wxs" module="_" />
22
33<t-popup visible="{{visible}}" placement="bottom" bind:visible-change="onPopupChange">
4- <view slot="content" style="{{ style }}" class="{{classPrefix}} {{prefix}}-class">
4+ <view
5+ slot="content"
6+ style="{{ style }}"
7+ class="{{classPrefix}} {{prefix}}-class"
8+ tabindex="-1"
9+ focus="{{true}}"
10+ >
511 <view class="{{classPrefix}}__toolbar" wx:if="{{header}}">
6- <view class="{{classPrefix}}__cancel {{prefix}}-class-cancel" wx:if="{{cancelBtn}}" bindtap="onCancel"
12+ <view
13+ class="{{classPrefix}}__cancel {{prefix}}-class-cancel"
14+ wx:if="{{cancelBtn}}"
15+ bindtap="onCancel"
16+ aria-role="button"
717 >{{cancelBtn}}</view
818 >
9- <view class="{{classPrefix}}__title {{prefix}}-class-title">{{title}}</view>
10- <view class="{{classPrefix}}__confirm {{prefix}}-class-confirm" wx:if="{{confirmBtn}}" bindtap="onConfirm"
19+ <view class="{{classPrefix}}__title {{prefix}}-class-title" focus="{{true}}" aria-label="{{title}}选择框"
20+ >{{title}}</view
21+ >
22+ <view
23+ class="{{classPrefix}}__confirm {{prefix}}-class-confirm"
24+ wx:if="{{confirmBtn}}"
25+ bindtap="onConfirm"
26+ aria-role="button"
1127 >{{confirmBtn}}</view
1228 >
1329 </view>
You can’t perform that action at this time.
0 commit comments