Files
uniapp-im-shop/pages/mall/list.vue

79 lines
1.8 KiB
Vue

<script setup>
import { reactive } from 'vue'
// 顶部分类选项
const topNavOptions = [
{ name: '全部', value: '0' },
{ name: '休闲零食', value: '1' },
{ name: '中外名酒', value: '2' },
{ name: '家用洗漱', value: '3' },
{ name: '家电家具', value: '4' },
{ name: '电子产品', value: '5' },
{ name: '户外用品', value: '6' }
]
const formData = reactive({
name: '',
type: '0'
})
const onTop = value => {
formData.type = value
}
</script>
<template>
<view class="mall-list">
<cb-search v-model="formData.name"></cb-search>
<view class="top-options">
<view
v-for="item in topNavOptions"
:key="item.value"
:class="{ active: item.value === formData.type }"
class="text"
@click="onTop(item.value)"
>
{{ item.name }}
</view>
</view>
</view>
</template>
<style lang="scss" scoped>
.mall-list {
padding: 24rpx;
.top-options {
overflow: hidden;
margin-top: 32rpx;
display: flex;
flex-direction: row;
white-space: nowrap; /* 重要:防止换行 */
-webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
.text + .text {
margin-left: 16rpx;
}
.text {
flex-shrink: 0;
padding: 8rpx 16rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
font-size: 28rpx;
color: #999999;
text-align: center;
font-style: normal;
text-transform: none;
background: #f4f4f4;
border-radius: 64rpx;
box-sizing: border-box;
}
.active {
padding: 6rpx 14rpx;
border-radius: 64rpx;
border: 2rpx solid #00d993;
color: #00d993;
}
}
}
</style>