4 Star 11 Fork 6

刘明/easyx

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
category.uvue 2.35 KB
Copy Edit Raw Blame History
刘明 authored 2023-12-21 15:10 . 1.0.0
<template>
<!-- #ifdef APP -->
<!-- <scroll-view style="flex:1"> -->
<!-- #endif -->
<view class="category">
<easy-sidebar :list="list" @change="onChange"></easy-sidebar>
<scroll-view class="right" @scroll="scroll" :scroll-top="scrollTop">
<view class="" v-for="(_,idx) in 4" :key="idx" ref="refList">
<text class="right-title">{{list[idx]}}</text>
<view class="right-box">
<view class="right-good" v-for="(item,index) in goodList" :key="index">
<image :src="cdn(item.image)" class="right-good-image"></image>
<text class="right-good-text">{{item.text}}</text>
</view>
</view>
</view>
</scroll-view>
</view>
<!-- #ifdef APP -->
<!-- </scroll-view> -->
<!-- #endif -->
</template>
<script>
type listItem = { text : string, image : string, link ?: string, price ?: string }
export default {
data() {
return {
list: ['手机数码', '服饰箱包', '家具百货', '美容美妆'] as string[],
goodList: [{ image: '/cate1.jpg', text: '全面屏手机' },
{ image: '/cate2.jpg', text: '全面屏手机' },
{ image: '/cate3.jpg', text: '全面屏手机' },
{ image: '/cate4.jpg', text: '全面屏手机' },
{ image: '/cate5.jpg', text: '全面屏手机' },
{ image: '/cate6.jpg', text: '全面屏手机' },
{ image: '/cate7.jpg', text: '全面屏手机' },] as listItem[],
scrollNode: [] as Element[] ,
scrollTop:0
};
},
onReady(){
this.scrollNode=this.$refs['refList'] as Element[];
},
methods: {
onChange(index: number) {
let rect = this.scrollNode[index].getBoundingClientRect();
this.scrollTop=rect.top
},
cdn(url : String) : string {
return "https://cdn.mzyun.tech/shop" + url;
},
scroll(e : ScrollEvent) {
console.log(e.detail.scrollTop)
},
}
}
</script>
<style lang="scss">
.category {
display: flex;
flex-direction: row;
.right {
flex: 1;
padding: 5px;
.right-title {
margin: 10px 0;
}
.right-box {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
background-color: #fff;
border-radius: 5px;
.right-good {
display: flex;
flex-direction: column;
align-items: center;
margin: 10px 0;
.right-good-image {
width: 60px;
height: 60px;
}
.right-good-text {
font-size: 14px;
}
}
}
}
}
</style>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liuming9157/easyx.git
git@gitee.com:liuming9157/easyx.git
liuming9157
easyx
easyx
master

Search

0d507c66 1850385 C8b1a773 1850385