File tree 5 files changed +74
-18
lines changed
5 files changed +74
-18
lines changed Original file line number Diff line number Diff line change 1
1
<block>
2
- <view class="pannel-item" bind:tap="onClickPicker" data-key="{{PICKER_KEY.CITY}}">
2
+ <label class="pannel-item" bind:tap="onClickPicker" data-key="{{PICKER_KEY.CITY}}" aria-role="button ">
3
3
<view class="pannel-label">城市</view>
4
4
<view class="pannel-text {{cityValue.length ? '' : 'empty'}}">{{cityCurrentValue || '选择城市'}}</view>
5
5
<t-icon name="chevron-right" color="rgba(0, 0, 0, 0.26)" size="24px" />
6
- </view >
7
- <view class="pannel-item" bind:tap="onClickPicker" data-key="{{PICKER_KEY.YEAR_SEASONS}}">
6
+ </label >
7
+ <label class="pannel-item" bind:tap="onClickPicker" data-key="{{PICKER_KEY.YEAR_SEASONS}}" aria-role="button ">
8
8
<view class="pannel-label">年份和季节</view>
9
9
<view class="pannel-text {{yearSeasonsValue.length ? '' : 'empty'}}">
10
10
{{yearSeasonsCurrentValue || '选择年份和季节' }}</view
11
11
>
12
12
<t-icon name="chevron-right" color="rgba(0, 0, 0, 0.26)" size="24px" />
13
- </view >
14
- <view class="pannel-item last" bind:tap="onClickPicker" data-key="{{PICKER_KEY.DATE}}">
13
+ </label >
14
+ <label class="pannel-item last" bind:tap="onClickPicker" data-key="{{PICKER_KEY.DATE}}" aria-role="button ">
15
15
<view class="pannel-label">日期</view>
16
16
<view class="pannel-text {{dateValue.length ? '' : 'empty'}}"> {{dateCurrentValue || '选择日期' }}</view>
17
17
<t-icon name="chevron-right" color="rgba(0, 0, 0, 0.26)" size="24px" />
18
- </view >
18
+ </label >
19
19
</block>
20
20
21
21
<!-- 城市不带标题 -->
Original file line number Diff line number Diff line change 5
5
<base />
6
6
</t-demo>
7
7
<t-demo desc="带标题选择器">
8
- <view class="pannel-item" bind:tap="onClickPicker" data-key="{{PICKER_KEY.CITY_TITLE}}">
8
+ <label class="pannel-item" bind:tap="onClickPicker" data-key="{{PICKER_KEY.CITY_TITLE}}" aria-role="button ">
9
9
<view class="pannel-label">城市</view>
10
10
<view class="pannel-text {{cityTitleValue.length ? '' : 'empty'}}"
11
11
>{{ cityTitleCurrentValue || '选择城市' }}</view
12
12
>
13
13
<t-icon name="chevron-right" color="rgba(0, 0, 0, 0.26)" size="24px" />
14
- </view >
15
- <view
14
+ </label >
15
+ <label
16
16
class="pannel-item"
17
17
bind:tap="onClickPicker"
18
18
data-title="选择年份和季节"
19
19
data-key="{{PICKER_KEY.YEAR_SEASONS_TITLE}}"
20
+ aria-role="button"
20
21
>
21
22
<view class="pannel-label">年份和季节</view>
22
23
<view class="pannel-text {{yearSeasonsTitleValue.length ? '' : 'empty'}}">
23
24
{{ yearSeasonsTitleCurrentValue || '选择年份和季节' }}</view
24
25
>
25
26
<t-icon name="chevron-right" color="rgba(0, 0, 0, 0.26)" size="24px" />
26
- </view>
27
- <view class="pannel-item" bind:tap="onClickPicker" data-title="选择日期" data-key="{{PICKER_KEY.DATE_TITLE}}">
27
+ </label>
28
+ <label
29
+ class="pannel-item"
30
+ bind:tap="onClickPicker"
31
+ data-title="选择日期"
32
+ data-key="{{PICKER_KEY.DATE_TITLE}}"
33
+ aria-role="button"
34
+ >
28
35
<view class="pannel-label">日期</view>
29
36
<view class="pannel-text {{dateTitleValue.length ? '' : 'empty'}}">
30
37
{{ dateTitleCurrentValue || '选择日期' }}</view
31
38
>
32
39
<t-icon name="chevron-right" color="rgba(0, 0, 0, 0.26)" size="24px" />
33
- </view >
40
+ </label >
34
41
</t-demo>
35
42
36
43
<!-- 城市带标题 -->
Original file line number Diff line number Diff line change @@ -89,6 +89,36 @@ export default class PickerItem extends SuperComponent {
89
89
} ) ;
90
90
} ) ;
91
91
} ,
92
+ onTap ( e ) {
93
+ const { index } = e . currentTarget . dataset ;
94
+ const {
95
+ itemHeight,
96
+ data : { options, classPrefix } ,
97
+ } = this ;
98
+ wx . createSelectorQuery ( )
99
+ . in ( this )
100
+ . select ( `#${ classPrefix } __group` )
101
+ . node ( )
102
+ . exec ( ( res ) => {
103
+ const scrollView = res [ 0 ] . node ;
104
+ scrollView . scrollTo ( {
105
+ top : 0 ,
106
+ } ) ;
107
+ } ) ;
108
+ this . setData ( {
109
+ duration : DefaultDuration ,
110
+ offset : - index * itemHeight ,
111
+ } ) ;
112
+ wx . nextTick ( ( ) => {
113
+ this . _selectedIndex = index ;
114
+ this . _selectedValue = options [ index ] ?. value ;
115
+ this . _selectedLabel = options [ index ] ?. label ;
116
+ this . parent ?. triggerColumnChange ( {
117
+ index,
118
+ column : this . columnIndex || 0 ,
119
+ } ) ;
120
+ } ) ;
121
+ } ,
92
122
93
123
// 刷新选中状态
94
124
update ( ) {
Original file line number Diff line number Diff line change 1
- <view
1
+ <scroll-view
2
+ enhanced="true"
3
+ id="{{classPrefix}}__group"
2
4
style="{{ customStyle }}"
3
5
class="{{classPrefix}}__group"
4
6
bind:touchstart="onTouchStart"
16
18
wx:key="index"
17
19
wx:for-item="option"
18
20
data-index="{{ index }}"
21
+ bind:tap="onTap"
19
22
>
20
23
{{option.label}}
21
24
</view>
22
25
</view>
23
- </view>
26
+ </scroll- view>
Original file line number Diff line number Diff line change 1
1
<t-popup visible="{{visible}}" placement="bottom" bind:visible-change="onPopupChange">
2
- <view slot="content" style="{{ customStyle }}" class="{{classPrefix}} {{prefix}}-class">
2
+ <view
3
+ slot="content"
4
+ style="{{ customStyle }}"
5
+ class="{{classPrefix}} {{prefix}}-class"
6
+ tabindex="-1"
7
+ focus="{{true}}"
8
+ >
3
9
<view class="{{classPrefix}}__toolbar" wx:if="{{header}}">
4
- <view class="{{classPrefix}}__cancel {{prefix}}-class-cancel" wx:if="{{cancelBtn}}" bindtap="onCancel"
10
+ <view
11
+ class="{{classPrefix}}__cancel {{prefix}}-class-cancel"
12
+ wx:if="{{cancelBtn}}"
13
+ bindtap="onCancel"
14
+ aria-role="button"
5
15
>{{cancelBtn}}</view
6
16
>
7
- <view class="{{classPrefix}}__title {{prefix}}-class-title">{{title}}</view>
8
- <view class="{{classPrefix}}__confirm {{prefix}}-class-confirm" wx:if="{{confirmBtn}}" bindtap="onConfirm"
17
+ <view class="{{classPrefix}}__title {{prefix}}-class-title" focus="{{true}}" aria-label="{{title}}选择框"
18
+ >{{title}}</view
19
+ >
20
+ <view
21
+ class="{{classPrefix}}__confirm {{prefix}}-class-confirm"
22
+ wx:if="{{confirmBtn}}"
23
+ bindtap="onConfirm"
24
+ aria-role="button"
9
25
>{{confirmBtn}}</view
10
26
>
11
27
</view>
You can’t perform that action at this time.
0 commit comments