分类侧栏

This commit is contained in:
shikong 2024-10-17 20:07:10 +08:00
parent eca6956729
commit 77ff420f02
Signed by: Shikong
GPG Key ID: BD85FF18B373C341
2 changed files with 51 additions and 2 deletions

View File

@ -26,5 +26,7 @@ button {
page { page {
background-color: #F8F8F8; background-color: #F8F8F8;
height: 100%;
width: 100%;
} }
</style> </style>

View File

@ -1,10 +1,57 @@
<script setup> <script setup>
import {reactive} from "vue";
const ctx = reactive({
current: 0,
categories: [
{
name: "外卖外送",
value: "takeaway"
},
{
name: "美团优选",
value: "optimization"
},
{
name: "美团餐饮",
value: "catering"
},
{
name: "休闲娱乐",
value: "playing"
},
{
name: "酒店旅游",
value: "tourism"
},
{
name: "交通出行",
value: "traffic"
}
]
})
function switchCategory(index) {
ctx.current = index
}
</script> </script>
<template> <template>
<view> <view class="flex w-full h-full">
分类页 <view class="w-1/4 h-full bg-gray-100">
<scroll-view class="h-full bg-gray-100">
<view v-for="(category, index) in ctx.categories" :key="index"
@click="switchCategory(index)"
:class="{'bg-white': index === ctx.current, 'bg-gray-100': index!== ctx.current}"
class="text-center p-4 rounded">
<text>{{ category.name }}</text>
</view>
</scroll-view>
</view>
<view class="flex-1 flex-grow-0 p-2">
123456
</view>
</view> </view>
</template> </template>