一起开发微信小程序
发表时间:2021-4-30
发布人:葵宇科技
浏览次数:98
每个小程序包含三个必不可少的文件
app.js app.json app.wxss
app.js: 脚本文件, 在这里监听并处理小程序的生命周期 以及全局变量
app.json:叫程序全局配置, 比如底部导航条样式, 窗口背景色,默认标题等
app.wxss: 全局样式表
官方文档 https://mp.weixin.qq.com/debug/wxadoc/dev/index.html
案例包含知识点:
默认请求必须为 https, 开发时手动开启调试即可在 http 环境下运行
上拉加载 下拉刷新
分享转发
自定义分享转发按钮
轮播图循环滚动
模版的使用
html解析转换为小程序可解析(借助于wxParser)
具体的不一一介绍, 看效果上代码



项目目录列表

WX20170713-184232.png
1、页面布局 底部导航 两个分类
2、主页面 顶部 轮播滚动 列表1、底部导航 由 app.json
页面路径"pages": ["pages/index/index","pages/detail/detail"],模版文件同样需要在app.json 声明, 首页 列表 item 使用"template": ["template/homeCell"],配置底部导航
"tabBar": {"color": "#7A7E83","selectedColor": "#ff3366","borderStyle": "black","backgroundColor": "#ffffff","list": [{"pagePath": "pages/index/index","iconPath": "image/nav_home_normal.png","selectedIconPath": "image/nav_home_selected.png","text": "数英"},{"pagePath": "pages/logs/logs","iconPath": "image/nav_my_normal.png","selectedIconPath": "image/nav_my_selected.png","text": "我"}]},另外可以配置 全部网络请求超时 networkTimeout 具体参照 开发文档
首页
index.wxml
<import src="../../template/homeCell.wxml" />//swiper 轮播控件 circular 属性 true 无限轮播<swiper class="banner" circular="true" indicator-dots="true" indicator-active-color="#ffffff" autoplay="true" interval="4000" duration="1000"><block wx:for="{{imgUrls}}"><swiper-item><image src="{{item.cover}}" class="slide-image" data-conType="{{item.conType}}" data-cover="{{item.cover}}" data-conId="{{item.conId}}" bindtap="clickAction"/></swiper-item></block></swiper><block wx:for="{{items}}"><template is="homeCell" data="{{item}}"/></block>//额外创建一个加载更多item<view class="loadmore" ><text class="more_title">正在加载...</text></view>//imgUrls json 数组//这里点击图片需要传递参数 详情 类型 详情顶部图片 详情 id//传参方式 data-conType="{{item.conType}}" 注意 获取时候 小写 data.contype 如下clickAction: function (event) {let data = https://www.wxapp-union.com/event.currentTarget.dataset;console.log('****' + data.conid);//点击打开新的页面并 传递参数wx.navigateTo({








