前端之微信小程序总结
来源:互联网 发布:cdlinux安装软件 编辑:程序博客网 时间:2024/06/08 22:40
**1、按条件设置class**<text wx:for="{{titles}}" wx:key="{{item}}" class="home-title {{index == activeIndex ? 'active' : ''}}" bindtap='changeClassify'> {{item.name}}</text>// index == activeIndex class为 "home-title active" 否则为 "home-title "**2、循环嵌套**// 普通的单次循环<text wx:for="{{titles}}" wx:key="{{index}}">{{item.name}}</text>//循环嵌套时使用 wx:for-item="XXX" <view wx:for="{{hotArr}}"> <view class="classify-title" bindtap="goClassifyPage"> <text>{{item.name}}</text> </view> <view class="classify-items"> <view class="classify-item" wx:for="{{item.data}}" wx:for-item="cell" wx:key="index"> <view> <text class="classify-item_name">{{cell.name}}</text> </view> </view> </view></view>//wxml<text wx:for="{{titles}}" wx:key="{{index}}" bindtap='changeClassify' data-id="{{index}}">{{item.name}}</text>**3、路由以及获取参数** //jsfunction changeClassify(e) { // let id = e.currentTarget.dataset.id; //跳转到classify 页面 wx.navigateTo({ url: '../classify/classify?id=' + id })}//classify 页面 获取参数onLoad: function (opts) { console.log(opts.id) console.log(this.options.id)}**4、上拉下拉**// 上拉加载更多onReachBottom: function() { if (this.data.next != null) { this.setData({ isHideLoadMore: false }) this.getNextPage() }}// 下拉刷新onPullDownRefresh: function() { this.refreshData()}**5、模板**/** * 1. 给template 设置name * 2. 组件传过来的值可以直接使用 hidden="{{!isloading}}" */<template name="loading"> <view class="weui-loadmore" hidden="{{!isloading}}"> <view class="weui-loading"></view> <view class="weui-loadmore__tips">正在加载</view> </view> </template>/** * 使用通用的template * 1. 按路径引入* 2. 设置 is 等于 template的name data="{{isloading}}" 给template的数据*/<import src="../template/loading.wxml"/><template is="loading" data="{{isloading}}"></template>
阅读全文
0 0
- 前端之微信小程序总结
- 前端之微信小程序
- 前端之微信小程序优化
- 前端之微信小程序搜索
- 前端之总结
- 前端之学习总结
- 前端之js总结
- 前端之编码规范总结
- 前端学习之第二阶段总结
- 前端之js方法总结
- 前端技术之小总结
- 前端外行的微信小程序瞎折腾之旅
- 一. 微信小程序实践之路<前端> ------- 轮播图的实现
- 百度前端面试经验之程序题
- 通过微信小程序看前端
- 通过微信小程序看前端
- 通过微信小程序看前端
- 前端微信小程序实战篇
- 【SDK使用】sdk print方式
- 第三周项目一(2)
- 45.Scala中Context Bounds代码实战及其在Spark中的应用源码解析
- Spring bean的加载过程
- 汽车结构
- 前端之微信小程序总结
- new与malloc的不同
- 直接插入排序-->希尔排序
- C语言10个经典小程序--致新手
- libsvm用法
- Poj3660 Cow Contest 【传递闭包】
- SimpleAudioEngine音效的使用导致游戏出现卡顿记录
- 32. 数据结构笔记之三十二广义表实现一
- linux mint18.2安装后配置简述