03:微信小程序案例2-2:本地生活

实现步骤

(一)创建项目

  • 项目名称:本地生活
  • 模板选择:不使用模板
    在这里插入图片描述

(二)创建页面

  • app.json里配置pages/grid/grid页面,删除其它页面
    在这里插入图片描述

(三)

  • 在项目根目录创建images目录,拷贝项目所需图片素材
    在这里插入图片描述

(四)编写页面结构

1、编写轮播区域页面结构

  • 轮播图有指示点,自动轮播,时间间隔3000毫秒
    在这里插入图片描述
<!--轮播图区域-->
<swiper indicator-dots="true" indicator-color="blue" indicator-active-color="red" autoplay="true" circular="true" interval="3000" >
    <swiper-item>
        <view class="item">
            <image src="/images/swiper01.png" mode="aspectFill" style="height: 100%;width: 100%;" />
        </view>
    </swiper-item>
    <swiper-item>
        <view class="item">
            <image src="/images/swiper02.png" mode="aspectFill" style="height: 100%;width: 100%;" />
        </view>
    </swiper-item>
    <swiper-item>
        <view class="item">
            <image src="/images/swiper03.png" mode="aspectFill" style="height: 100%;width: 100%;" />
        </view>
    </swiper-item>
</swiper>
  • 预览效果(看不见图片,可以看见指示点在循环)
    在这里插入图片描述

2、编写九宫格区域页面结构

  • view组件里嵌套9个view组件
    在这里插入图片描述
<!--九宫格区域-->
<view class="grids">
    <view class="grids-item">
        <image src="/images/food.png"/>
        <text>美食</text>
    </view>
    <view class="grids-item">
        <image src="/images/fitup.png"/>
        <text>装修</text>
    </view>
    <view class="grids-item">
        <image src="/images/bath.png"/>
        <text>洗浴</text>
    </view>
    <view class="grids-item">
        <image src="/images/car.png"/>
        <text>汽车</text>
    </view>
    <view class="grids-item">
        <image src="/images/sing.png"/>
        <text>唱歌</text>
    </view>
    <view class="grids-item">
        <image src="/images/house.png"/>
        <text>住宿</text>
    </view>
    <view class="grids-item">
        <image src="/images/study.png"/>
        <text>学习</text>
    </view>
    <view class="grids-item">
        <image src="/images/work.png"/>
        <text>工作</text>
    </view>
    <view class="grids-item">
        <image src="/images/marry.png"/>
        <text>结婚</text>
    </view>
</view>
  • 预览效果(显然不是我们想要的结果)
    在这里插入图片描述

(五)编写页面样式

1、编写轮播图区域页面样式

  • 设置swiper容器高度:350rpx,设置图片容器的高度和宽度。

在这里插入图片描述

/* pages/grid/grid.wxss */
.item{
    height: 100%;
    width: 100%;
}
  • 预览效果
    在这里插入图片描述

2、编写九宫格区域页面样式

  • 整体页面样式
.grids {
    display: flex;
    flex-wrap: wrap; /* 自动绕行 */
}
  • 每个格子页面样式
.grids .grid-item {
    width: 250rpx; /* 750 ÷ 3 = 250 */
    height: 250rpx;
    border-right: 1rpx solid #eee;
    border-bottom: 1rpx solid #eee;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* 清除第3个格子的右边框 */
.grids .grid-item:nth-child(3) {
    border-right: 0;
}
/* 清除第6个格子的右边框 */
.grids .grid-item:nth-child(6) {
    border-right: 0;
}
/* 清除第9个格子的右边框 */
.grids .grid-item:nth-child(9) {
    border-right: 0;
}
  • 每个格子中的图片和文字的页面样式
/* 每个格子内的图片样式 */
.grids .grid-item image {
    width: 90rpx;
    height: 90rpx;
}
/* 每个格子内的文本样式 */
.grids .grid-item text {
    color: #999;
    font-size: 35rpx;
    margin-top: 20rpx;
}

(六)查看模拟机效果

  • 真机调试—— 二维码真机调试
    -

  • 扫码
    - \

  • 手机截屏
    在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值