首页导航

This commit is contained in:
jqtmviyu@gmail.com 2021-02-21 21:45:38 +08:00
parent 6fb7cb8598
commit e30c8cd232
2 changed files with 37 additions and 3 deletions

View File

@ -26,4 +26,8 @@
font-size: 28rpx; font-size: 28rpx;
color: #666; color: #666;
} }
image{
/* 宽度等于父盒子的宽度, 才不会主动撑开 */
Width:100%;
}
</style> </style>

View File

@ -10,6 +10,14 @@
<u-swiper :list="swiperList" height="340" border-radius="0"></u-swiper> <u-swiper :list="swiperList" height="340" border-radius="0"></u-swiper>
</view> </view>
<!-- 3. 导航 -->
<view class="nav">
<navigator class="nav_item" v-for="item in catitems" :key="item.image_src">
<image :src="item.image_src" mode="widthFix"></image>
<!-- widthFix 缩放模式宽度不变高度自动变化保持原图宽高比不变 -->
</navigator>
</view>
</view> </view>
</template> </template>
@ -17,12 +25,16 @@
export default { export default {
data() { data() {
return { return {
swiperList: [] swiperList: [],
catitems: []
} }
}, },
// //
onLoad() { onLoad() {
this.getSwiper(); //
this.getSwiper()
//
this.getCatitems()
}, },
methods: { methods: {
// getSwiper(){ // getSwiper(){
@ -32,15 +44,23 @@
// }) // })
// } // }
//
async getSwiper(){ async getSwiper(){
const { message } = await this.$u.api.getSwiperdata() const { message } = await this.$u.api.getSwiperdata()
this.swiperList = message.map(v=>({...v,image:v.image_src})) this.swiperList = message.map(v=>({...v,image:v.image_src}))
} },
//
async getCatitems(){
const { message } = await this.$u.api.getCatitems()
this.catitems = message
}
} }
} }
</script> </script>
<style lang="scss"> <style lang="scss">
/* 搜索 */
.search { .search {
/* /*
设计稿375px 设计稿375px
@ -53,4 +73,14 @@
轮播图750px宽, 340px高 轮播图750px宽, 340px高
*/ */
} }
/* 导航 */
.nav {
display: flex;
.nav_item {
flex: 1;
padding: 20rpx;
}
}
</style> </style>