|
1 | 1 | <template> |
2 | 2 | <view class="uni-indexed-list" ref="list" id="list"> |
3 | | - <scroll-view :scroll-into-view="scrollViewId" class="uni-indexed-list__scroll" scroll-y> |
4 | | - <view v-for="(list, idx) in lists" :key="idx" :id="'uni-indexed-list-' + list.key"> |
5 | | - <uni-indexed-list-item :list="list" :loaded="loaded" :idx="idx" :showSelect="showSelect" @itemClick="onClick"></uni-indexed-list-item> |
6 | | - </view> |
7 | | - </scroll-view> |
| 3 | + <!-- #ifdef APP-NVUE --> |
| 4 | + <list class="uni-indexed-list__scroll" scrollable="true" show-scrollbar="false"> |
| 5 | + <cell v-for="(list, idx) in lists" :key="idx" :ref="'uni-indexed-list-' + list.key"> |
| 6 | + <!-- #endif --> |
| 7 | + <!-- #ifndef APP-NVUE --> |
| 8 | + <scroll-view :scroll-into-view="scrollViewId" class="uni-indexed-list__scroll" scroll-y> |
| 9 | + <view v-for="(list, idx) in lists" :key="idx" :id="'uni-indexed-list-' + list.key"> |
| 10 | + <!-- #endif --> |
| 11 | + <uni-indexed-list-item :list="list" :loaded="loaded" :idx="idx" :showSelect="showSelect" @itemClick="onClick"></uni-indexed-list-item> |
| 12 | + <!-- #ifndef APP-NVUE --> |
| 13 | + </view> |
| 14 | + </scroll-view> |
| 15 | + <!-- #endif --> |
| 16 | + <!-- #ifdef APP-NVUE --> |
| 17 | + </cell> |
| 18 | + </list> |
| 19 | + <!-- #endif --> |
8 | 20 | <view :class="touchmove ? 'uni-indexed-list__menu--active' : ''" @touchstart="touchStart" @touchmove.stop="touchMove" @touchend="touchEnd" class="uni-indexed-list__menu"> |
9 | 21 | <view v-for="(list, key) in lists" :key="key" class="uni-indexed-list__menu-item"> |
10 | 22 | <text class="uni-indexed-list__menu-text" :class="touchmoveIndex == key ? 'uni-indexed-list__menu-text--active' : ''">{{ list.key }}</text> |
|
18 | 30 | <script> |
19 | 31 | import uniIcons from '@/components/uni-icons/uni-icons.vue' |
20 | 32 | import uniIndexedListItem from './uni-indexed-list-item.vue' |
| 33 | + // #ifdef APP-NVUE |
| 34 | + const dom = weex.requireModule('dom'); |
| 35 | + // #endif |
21 | 36 | // #ifdef APP-PLUS |
22 | 37 | function throttle(func, delay) { |
23 | 38 | var prev = Date.now(); |
|
40 | 55 | } |
41 | 56 | let item = this.lists[index] |
42 | 57 | if (item) { |
| 58 | + // #ifndef APP-NVUE |
43 | 59 | this.scrollViewId = 'uni-indexed-list-' + item.key |
44 | 60 | this.touchmoveIndex = index |
| 61 | + // #endif |
| 62 | + // #ifdef APP-NVUE |
| 63 | + dom.scrollToElement(this.$refs['uni-indexed-list-' + item.key][0], { |
| 64 | + animated: false |
| 65 | + }) |
| 66 | + this.touchmoveIndex = index |
| 67 | + // #endif |
45 | 68 | } |
46 | 69 | } |
47 | 70 | const throttleTouchMove = throttle(touchMove, 40) |
48 | 71 | // #endif |
49 | | - // #ifdef APP-NVUE |
50 | | - const dom = weex.requireModule('dom'); |
51 | | - // #endif |
52 | 72 | export default { |
53 | 73 | name: 'UniIndexedList', |
54 | 74 | components: { |
|
0 commit comments