1---home.wxml 区域 (页面整体的标签)
<!-- 轮播图区域 -->
<swiper indicator-dots circular autoplay>
<swiper-item wx:for="{{SwiperArr}}" wx:key="id">
<image src="{{item.image}}"></image>
</swiper-item>
</swiper>
<!-- 九宫格区域 -->
<view class="grid-Arr">
<view class="grid-item" wx:for="{{GridArr}}" wx:key="id">
<image src = "{{item.icon}}"></image>
<text>{{item.name}}</text>
</view>
</view>
<!-- 图片区域 -->
<view class="imgBox">
<image src="/images/link-01.png" mode="widthFix"></image>
<image src="/images/link-02.png" mode="widthFix"></image>
</view>
2---app.json区域 (全局配置文件){
"pages": [
"pages/home/home",
"pages/message/message",
"pages/contact/contact"
],
"window": {
"navigationBarTextStyle": "white",
"navigationBarTitleText": "本地生活",
"navigationBarBackgroundColor": "#2b4b6b"
},
"tabBar": {
"list": [{
"pagePath": "pages/home/home",
"text": "首页",
"iconPath": "/images/首页-置灰.png",
"selectedIconPath": "/images/1_导航-默认 .png"
},{
"pagePath": "pages/message/message",
"text": "消息",
"iconPath": "/images/消息-置灰.png",
"selectedIconPath": "/images/即时聊天.png"
},{
"pagePath": "pages/contact/contact",
"text": "联系人",
"iconPath": "/images/填选购人.png",
"selectedIconPath": "/images/1_用户管理.png"
}]
},
"style": "v2",
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents"
}
3-home.js 区域 (存放home页面的数据)Page({
/**
* 页面的初始数据
*/
data: {
//轮播图数组SwiperArr : \[\],
//九宫格 数组GridArr : \[\],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getSwiperArr()
this.getGridArr()
},
//获取轮播图数据
getSwiperArr(){
wx.request({
// https://applet-base-api-t.itheima.net/slides
url: 'https://applet-base-api-t.itheima.net/slides',
method :'GET',
success: (res) => {
this.setData({
SwiperArr: res.data
})
}
})
},
// 获取九宫格数据
getGridArr(){
wx.request({
url: 'https://applet-base-api-t.itheima.net/categories',
method : "GET",
success : (res) => {
this.setData({
GridArr :res.data
})
}
})
},
4--home.wxss ( home页面的渲染)/* 轮播图区域start*/
swiper{
height: 350rpx;
}
swiper image {
width: 100%;
height: 100%;
}
/* 轮播图区域end */
/*九宫格区域start*/
.grid-Arr{
display: flex;
flex-wrap: wrap; /*换行*/
}
.grid-item{
width: 33.33%;
height: 200rpx;
display: flex;
flex-direction: column;/*主轴纵向*/
/*居中*/
align-items: center;
justify-content: center;
border-bottom: 1px solid #ededde;
border-right: 1px solid #ededde;
box-sizing: border-box;
}
.grid-item image{
width: 60rpx;
height: 60rpx ;
}
.grid-item text{
font-size: 24rpx;
margin-top: 10rpx;
color: gray;
}
/*九宫格区域end*/
/*图片区域start*/
.imgBox{
display: flex;
justify-content: space-around;
padding-top: 20rpx;
}
.imgBox image{
width: 45%;
height: 200rpx;
}
/* 图片区域 end*/
5--效果展示
开发微信小程序 案例01-本地生活首页页面
迷雾yx2024-10-01 15:07
相关推荐
小徐_233318 小时前
Wot UI 2.2.0 发布:Button 新增 subtle,VideoPreview 预览体验继续增强蜗牛前端3 天前
codex 全流程开发上线的高颜值礼簿小程序爱勇宝7 天前
我想认真做一件小事:让孩子和家长更好地互动唯火锅不可辜负7 天前
避坑指南:iOS 下 scroll-view 嵌套 fixed 布局的“翻车”现场与修复didiplus7 天前
运维人的随身神器:我把25个常用工具塞进了微信小程序一份执念8 天前
uni-app 小程序分包限制处理与主包体积优化实战一份执念8 天前
ECharts 安装与使用完全指南:从全量引入到小程序分包优化skiyee9 天前
🔥UniApp 仅需 5 行代码!实现所有页面中控制应用主题变化Jinkey10 天前
要用户手机号真的是为了打骚扰电话吗?浅谈微信生态会员账号体系与资产合并用户43242810611412 天前
微信小程序从0到1接入微信支付的完整攻略