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

Commit

Permalink
chore(indexes demo): format change
Browse files Browse the repository at this point in the history
  • Loading branch information
b2nil committed Sep 7, 2020
1 parent 7cd25a8 commit b0697d0
Showing 1 changed file with 59 additions and 62 deletions.
121 changes: 59 additions & 62 deletions src/pages/navigation/indexes/index.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
<template>
<view
class="page"
style="height: 100vh;"
>
<view style="height: 100%;">
<at-indexes
topKey="Top"
:list="mockdata"
@click="handleClick"
@scroll-into-view="handleScrollIntoView"
>
<view class="custom-area">
用户自定义内容
<at-search-bar
placeholder="跳转到指定Key"
:value="searchbarValue"
@change="handleChange"
@action-click="handleActionClick"
/>
</view>
</at-indexes>
<view class="page">
<view style="height: 100vh;">
<at-indexes
topKey="Top"
:list="mockdata"
@click="handleClick"
@scroll-into-view="handleScrollIntoView"
>
<view class="custom-area">
用户自定义内容
<at-search-bar
placeholder="跳转到指定Key"
:value="searchbarValue"
@change="handleChange"
@action-click="handleActionClick"
/>
</view>
</at-indexes>
</view>
</view>
</template>

<script lang="ts">
Expand All @@ -33,55 +30,55 @@ import mockData from './mock-data'
export default defineComponent({
components: {
AtIndexes,
AtSearchBar,
},
components: {
AtIndexes,
AtSearchBar,
},
setup() {
const searchbarValue = ref('')
const mockdata = ref(mockData)
setup() {
const searchbarValue = ref('')
const mockdata = ref(mockData)
let scrollIntoView = (key) => {
Taro.showToast({
title: `scrollIntoView: ${key}`,
icon: 'none'
})
}
const scrollIntoView = ref((key) => {
Taro.showToast({
title: `scrollIntoView: ${key}`,
icon: 'none'
})
})
function handleClick(item) {
Taro.showToast({
title: `onClick: ${JSON.stringify(item)}`,
icon: 'none'
})
}
function handleClick(item) {
Taro.showToast({
title: `onClick: ${JSON.stringify(item)}`,
icon: 'none'
})
}
function handleActionClick() {
if (!searchbarValue.value) {
return
}
setTimeout(() => {
scrollIntoView && scrollIntoView(searchbarValue.value.toUpperCase())
}, 10);
}
function handleActionClick() {
if (!searchbarValue.value) {
return
}
function handleChange(value) {
searchbarValue.value = value
}
scrollIntoView.value(searchbarValue.value.toUpperCase())
searchbarValue.value = ''
}
function handleScrollIntoView(fn) {
scrollIntoView = fn
}
function handleChange(value) {
searchbarValue.value = value
}
function handleScrollIntoView(fn) {
scrollIntoView.value = fn
}
return {
mockdata,
searchbarValue,
handleClick,
handleChange,
handleActionClick,
handleScrollIntoView
}
return {
mockdata,
searchbarValue,
handleClick,
handleChange,
handleActionClick,
handleScrollIntoView
}
}
})
</script>

Expand Down

0 comments on commit b0697d0

Please sign in to comment.