案例2-2 本地生活

(一)创建项目

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

(二)创建页面

  • app.json里配置pages/grid/grid页面,手动删除index,目录,设置导航栏
    在这里插入图片描述

(三)准备图片素材

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

(四)编写页面结构

在这里插入图片描述

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

  • 源代码
<!--pages/grid/grid.wxml-->
<!--轮播图区域-->
<swiper indicator-dots="true" indicator-active-color="blue"
indicator-active-color="red" autoplay="true" circular="true"
interval="3000">
    <swiper-item>
        <view class="item">
            <image src="/images/1.png" mode="aspectFill" 
            style="width: 100%; height: 100%;" />
        </view>
    </swiper-item>
    <swiper-item>
        <view class="item">
            <image src="/images/2.png" mode="aspectFill" 
            style="width: 100%; height: 100%;" />
        </view>
    </swiper-item>
    <swiper-item>
        <view class="item">
            <image src="/images/3.png" mode="aspectFill" 
            style="width: 100%; height: 100%;" />
        </view>
    </swiper-item>
</swiper>
  • 预览效果
    在这里插入图片描述

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

  • 源代码
<!--九宫格区域-->
<view class="grids">
    <view class="gird-item">
        <image src="/images/food.png" />
        <text>美食</text>
    </view>
    <view class="gird-item">
        <image src="/images/fitup.png" />
        <text>装修</text>
    </view>
    <view class="gird-item">
        <image src="/images/bath.png" />
        <text>洗浴</text>
    </view>
    <view class="gird-item">
        <image src="/images/sing.png" />
        <text>唱歌</text>
    </view>
    <view class="gird-item">
        <image src="/images/house.png"/>
        <text>住宿</text>
    </view>
    <view class="gird-item">
        <image src="/images/work.png" />
        <text>工作</text>
    </view>
    <view class="gird-item">
        <image src="/images/marry.png" />
        <text>结婚</text>
    </view>
</view>
  • 源代码截图
    在这里插入图片描述
  • 预览效果
    在这里插入图片描述

(五)编写页面样式

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

  • 设置swiper容器高度:350rpx,设置图片容器的高度和宽度
  • 在这里插入图片描述
    在这里插入图片描述

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

  • 整体页面样式
.item{
  height: 100%;
  width: 100%;
}
  • 每个格子页面样式
    在这里插入图片描述

  • 每个格子中的图片和文字的页面样式

/*清除第三个格子的右边框*/
.grids .grid-item:nth-child(3) {
   border-right: 0;
}
/*清除第六个格子的右边框*/
.grids .grid-item:nth-child(6) {
   border-right: 0;
}
/*清除第九个格子的右边框*/
.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;
}

(六)真机调试预览效果

1、点击真机调试,自动真机调试也可以点击二维码真机调试

在这里插入图片描述

2、点击编译并自动调试,以下是效果

在这里插入图片描述

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值