微信小程序-案例:本地生活-首页(不使用网络数据请求)

一、

1.页面效果:

二、

1.新建项目并添加页面

在app.json文件中:

复制代码
"pages": [
    "pages/home/home",
    "pages/message/message",
    "pages/contact/contact"
  ]

2.配置导航栏效果

在app.json文件中:

复制代码
"window": {
    "backgroundTextStyle": "light",
    "navigationBarTitleText": "本地生活",
    "navigationBarBackgroundColor": "#2b4b6b",
    "navigationBarTextStyle": "white"
  }

如图:

3.配置tabBar效果

在app.json文件中:

复制代码
"tabBar": {
    "list": [{
      "pagePath": "pages/home/home",
      "text": "首页",
      "iconPath": "/image/home.png",
      "selectedIconPath": "/image/home-active.png"
    },{
      "pagePath": "pages/message/message",
      "text": "消息页面",
      "iconPath": "/image/message.png",
      "selectedIconPath": "/image/message-active.png"
    },{
      "pagePath": "pages/contact/contact",
      "text": "联系我们",
      "iconPath": "/image/contact.png",
      "selectedIconPath": "/image/contact-active.png"
    }]
 }

效果如下:

4.实现轮播图效果

将所需的轮播图图片放入images文件夹中的swiper文件夹中

在home.js文件中:

复制代码
  data: {
    swiperList:[
      '/images/swiper/swiper-01.jpg',
      '/images/swiper/swiper-02.jpg'
    ]
  }

在home.wxml文件中:

XML 复制代码
<!-- 轮播图区域 -->
<swiper indicator-dots circular>
  <swiper-item wx:for="{{swiperList}}">
    <image src="{{item}}"></image>
  </swiper-item>
</swiper>

美化图片:

在home.wxss文件中:

css 复制代码
swiper {
  height: 350rpx;
}

swiper image {
  width: 100%;
  height: 100%;
}

效果如图:

5.实现九宫格效果

将所需的九宫格图片放入images文件夹中的nine文件夹中

在home.js文件中:

css 复制代码
  data: {
    swiperList:[
      '/images/swiper/swiper-01.jpg',
      '/images/swiper/swiper-02.jpg'
    ],
    gridList:[
      {'name':'辅导班','icon':'/images/nine/fudaoban.jpg'},
      {'name':'结婚','icon':'/images/nine/jiehun.jpg'},
      {'name':'美食','icon':'/images/nine/meishi.jpg'},
      {'name':'卡拉OK','icon':'/images/nine/ok.jpg'},
      {'name':'汽车保养','icon':'/images/nine/qichebaoyang.jpg'},
      {'name':'洗浴足疗','icon':'/images/nine/xiyuzuliao.jpg'},
      {'name':'找工作','icon':'/images/nine/zhaogongzuo.jpg'},
      {'name':'装修','icon':'/images/nine/zhuangxiu.jpg'},
      {'name':'租房','icon':'/images/nine/zufang.jpg'},

    ]
  }

在home.wxml文件中:

XML 复制代码
<!-- 九宫格区域 -->
<view class="grid-list">
  <view class="grid-item" wx:for="{{gridList}}">
    <image src="{{item.icon}}"></image>
    <text>{{item.name}}</text>
  </view>
</view>

哦对九宫格这里grid不要打错成gird了!!!

美化图片:

在home.wxss文件中:

css 复制代码
.grid-list {
  /* flex布局 */
  display: flex;
  /* 允许换行 */
  flex-wrap: wrap;
  /* 添加右侧边框 */
  border-right: 1rpx solid #efefef;
  /* 添加底部边框 */
  border-bottom: 1rpx solid #efefef;
}

.grid-item {
  width: 33.33%;
  height: 200rpx;
  display: flex;
  /* 纵向布局 */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* 添加左侧边框 */
  border-left: 1rpx solid #efefef;
  /* 添加顶部边框 */
  border-top: 1rpx solid #efefef;
  /* 改变box方式 */
  box-sizing: border-box;
}

.grid-item image {
  width: 60rpx;
  height: 60rpx;
}

.grid-item text {
  font-size: 24rpx;
  /* 设置文本和图片之间距离 */
  margin-top: 10rpx;
}

效果如下:

6.实现底部图片效果

将所需的图片放入images文件夹中的picture文件夹中

在home.wxml文件中:

XML 复制代码
<!-- 底部图片区域 -->
<view class="img-box">
  <image src="/images/picture/link-01.png"></image>
  <image src="/images/picture/link-02.png"></image>
</view>

美化图片:

在home.wxss文件中:

css 复制代码
.img-box {
  display: flex;
  padding: 20rpx 10rpx;
  justify-content: space-around;
}

.img-box image {
  height: 100px;
}

效果如下:

over

相关推荐
不爱学习小趴菜10 小时前
uniapp微信小程序无法屏蔽右上角胶囊按钮(...)问题解决方案
微信小程序·小程序·uni-app
plmm烟酒僧11 小时前
《微信小程序demo开发》第一部分-编写页面逻辑
javascript·微信小程序·小程序·html·微信开发者工具·小程序开发
Stara051112 小时前
微信小程序配置与导航深度指南—全局/页面配置解析与高效传参策略V1.2
javascript·微信小程序·html·模块化开发·页面导航·wxs脚本·小程序api
全栈小512 小时前
【小程序】微信小程序input设置readonly只读属性无效,这是怎么回事呢
微信小程序·小程序·notepad++
sheji34161 天前
【开题答辩全过程】以 基于微信小程序的摄影器材租赁系统设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
毕设源码-邱学长1 天前
【开题答辩全过程】以 基于微信小程序的社团管理系统的设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
风景的人生2 天前
小程序接收respose中的数组
前端·微信小程序·小程序
谷哥的小弟2 天前
图片上传自动人脸打码:微信小程序隐私保护实践
微信小程序·人脸识别·图片上传·马赛克·隐私保护·自动打码
夏天想2 天前
微信小程序使用pinia-plugin-persistedstate报错找不到localstorage
微信小程序·小程序
sheji34162 天前
【开题答辩全过程】以 基于微信小程序的社区养老积分银行系统的设计为例,包含答辩的问题和答案
微信小程序·小程序