零、知识储备
一 、案例实现
注意操作前不要把局部的JS文件全删,会出现页面不显示情况
1、页面编写
(一)第一部分编写
- 使用
swiper/swiper-item
组件编写轮播图
<swiper indicator-dots="true" autoplay="true" interval="3000" circular>
<swiper-item>
<image src="/images/swiper01.jpg"/>
</swiper-item>
<swiper-item>
<image src="/images/swiper02.jpg"/>
</swiper-item>
</swiper>
(二)第二部分编写
<view class="grids">
<view class="item">
<image src="/images/shi.png"/>
<text>美食</text>
</view>
<view class="item">
<image src="/images/xiu.png"/>
<text>装修</text>
</view>
<view class="item">
<image src="/images/yu.png"/>
<text>洗浴</text>
</view>
<view class="item">
<image src="/images/che.png"/>
<text>汽车</text>
</view>
<view class="item">
<image src="/images/chang.png"/>
<text>唱歌</text>
</view>
<view class="item">
<image src="/images/fang.png"/>
<text>住宿</text>
</view>
<view class="item">
<image src="/images/xue.png"/>
<text>学习</text>
</view>
<view class="item">
<image src="/images/gong.png"/>
<text>工作</text>
</view>
<view class="item">
<image src="/images/hun.png"/>
<text>结婚</text>
</view>
</view>
2、页面样式编写
(一)轮播图样式
swiper{
height: 350rpx;
}
swiper image{
width: 100%;
height: 100%;
}
(二)九宫格样式
.grids{
display: flex;
flex-wrap: wrap;
}
.grids .item{
width: 250rpx;
height: 250rpx;
border-right: 1rpx solid #eee;
border-bottom:1rpx solid #eee ;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.grids .item:nth-child(3){
border-right: 0;
}
.grids .item:nth-child(6){
border-right: 0;
}
.grids .item:nth-child(9){
border-right: 0;
}
.grids .item image{
width: 70rpx;
height: 70rpx;
}
.grids .item text{
font-size: 28rpx;
margin-top: 20rpx;
}
二、效果展示