Skip to content
This repository was archived by the owner on Dec 6, 2021. It is now read-only.

Commit b0697d0

Browse files
committed
chore(indexes demo): format change
1 parent 7cd25a8 commit b0697d0

File tree

1 file changed

+59
-62
lines changed

1 file changed

+59
-62
lines changed

src/pages/navigation/indexes/index.vue

+59-62
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
<template>
2-
<view
3-
class="page"
4-
style="height: 100vh;"
5-
>
6-
<view style="height: 100%;">
7-
<at-indexes
8-
topKey="Top"
9-
:list="mockdata"
10-
@click="handleClick"
11-
@scroll-into-view="handleScrollIntoView"
12-
>
13-
<view class="custom-area">
14-
用户自定义内容
15-
<at-search-bar
16-
placeholder="跳转到指定Key"
17-
:value="searchbarValue"
18-
@change="handleChange"
19-
@action-click="handleActionClick"
20-
/>
21-
</view>
22-
</at-indexes>
2+
<view class="page">
3+
<view style="height: 100vh;">
4+
<at-indexes
5+
topKey="Top"
6+
:list="mockdata"
7+
@click="handleClick"
8+
@scroll-into-view="handleScrollIntoView"
9+
>
10+
<view class="custom-area">
11+
用户自定义内容
12+
<at-search-bar
13+
placeholder="跳转到指定Key"
14+
:value="searchbarValue"
15+
@change="handleChange"
16+
@action-click="handleActionClick"
17+
/>
2318
</view>
19+
</at-indexes>
2420
</view>
21+
</view>
2522
</template>
2623

2724
<script lang="ts">
@@ -33,55 +30,55 @@ import mockData from './mock-data'
3330
3431
export default defineComponent({
3532
36-
components: {
37-
AtIndexes,
38-
AtSearchBar,
39-
},
33+
components: {
34+
AtIndexes,
35+
AtSearchBar,
36+
},
4037
41-
setup() {
42-
const searchbarValue = ref('')
43-
const mockdata = ref(mockData)
38+
setup() {
39+
const searchbarValue = ref('')
40+
const mockdata = ref(mockData)
4441
45-
let scrollIntoView = (key) => {
46-
Taro.showToast({
47-
title: `scrollIntoView: ${key}`,
48-
icon: 'none'
49-
})
50-
}
42+
const scrollIntoView = ref((key) => {
43+
Taro.showToast({
44+
title: `scrollIntoView: ${key}`,
45+
icon: 'none'
46+
})
47+
})
5148
52-
function handleClick(item) {
53-
Taro.showToast({
54-
title: `onClick: ${JSON.stringify(item)}`,
55-
icon: 'none'
56-
})
57-
}
49+
function handleClick(item) {
50+
Taro.showToast({
51+
title: `onClick: ${JSON.stringify(item)}`,
52+
icon: 'none'
53+
})
54+
}
5855
59-
function handleActionClick() {
60-
if (!searchbarValue.value) {
61-
return
62-
}
63-
setTimeout(() => {
64-
scrollIntoView && scrollIntoView(searchbarValue.value.toUpperCase())
65-
}, 10);
66-
}
56+
function handleActionClick() {
57+
if (!searchbarValue.value) {
58+
return
59+
}
6760
68-
function handleChange(value) {
69-
searchbarValue.value = value
70-
}
61+
scrollIntoView.value(searchbarValue.value.toUpperCase())
62+
searchbarValue.value = ''
63+
}
7164
72-
function handleScrollIntoView(fn) {
73-
scrollIntoView = fn
74-
}
65+
function handleChange(value) {
66+
searchbarValue.value = value
67+
}
68+
69+
function handleScrollIntoView(fn) {
70+
scrollIntoView.value = fn
71+
}
7572
76-
return {
77-
mockdata,
78-
searchbarValue,
79-
handleClick,
80-
handleChange,
81-
handleActionClick,
82-
handleScrollIntoView
83-
}
73+
return {
74+
mockdata,
75+
searchbarValue,
76+
handleClick,
77+
handleChange,
78+
handleActionClick,
79+
handleScrollIntoView
8480
}
81+
}
8582
})
8683
</script>
8784

0 commit comments

Comments
 (0)