• 微信小程序之本地生活(九宫格)


    一.创建项目

    创建新的项目,名称为:本地生活
    在这里插入图片描述

    二.配置修改json

    在app.json中删除其他页面 将index改为grid 自动生成新的文件
    添加自己的轮播图
    源代码:

    
    
    <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/111.jpg" mode="aspectFill" style="width: 100%; height:100%" />
    view>
    swiper-item>
    <swiper-item>
    <view class="item">
    <image src="/images/222.jpg" mode="aspectFill" style="width: 100%; height:100%" />
    view>
    swiper-item>
    <swiper-item>
    <view class="item">
    <image src="/images/333.jpg" mode="aspectFill" style="width: 100%; height:100%" />
    view>
    swiper-item>
    swiper>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    在这里插入图片描述
    看不见图片,但是可以看见指示点在动,是因为还未设置图片

    三.编写WXML

    
    <view class="grids">
    <view class="grid-item">
    <image src="/images/food.png"/>
    <text>美食text>
    view>
    <view class="grid-item">
    <image src="/images/fitup.png"/>
    <text>装修text>
    view>
    
    <view class="grid-item">
    <image src="/images/bath.png"/>
    <text>洗浴text>
    view>
    
    <view class="grid-item">
    <image src="/images/car.png"/>
    <text>汽车text>
    view>
    <view class="grid-item">
    <image src="/images/sing.png"/>
    <text>唱歌text>
    view>
    
    <view class="grid-item">
    <image src="/images/house.png"/>
    <text>住宿text>
    view>
    
    <view class="grid-item">
    <image src="/images/study.png"/>
    <text>学习text>
    view>
    <view class="grid-item">
    <image src="/images/work.png"/>
    <text>工作text>
    view>
    
    <view class="grid-item">
    <image src="/images/marry.png"/>
    <text>结婚text>
    view>
    view>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45

    预览效果,图片还未规则
    在这里插入图片描述
    设置WXSS,让轮播图照片显现出来

    四.编写WXSS

    /* pages/grid/grid.wxss */
    
    .item{
      width: 100%;
      height: 100%;
    }
    .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;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45

    五.最终效果

    在这里插入图片描述

  • 相关阅读:
    github教程
    Java设计模式之观察者模式
    【openscreen 】FrameId
    vim之一键替换
    Java 方法中循环调用具有事务的方法
    CASAIM自动激光3D测量系统助力海外家电组装企业IQC来料检测装配尺寸测量
    [附源码]java毕业设计车辆违章信息管理系统
    CNN经典架构
    计算机毕业设计Java厨艺交流平台(源码+系统+mysql数据库+lw文档)
    Rust常用特型之ToOwned特型
  • 原文地址:https://blog.csdn.net/qq_62512326/article/details/133693346