小程序for循环对象
来源:互联网 发布:虚拟机网络连接不上 编辑:程序博客网 时间:2024/05/21 18:32
<view class="container log-list"> <block wx:for="{{logs}}" wx:for-item="log" wx:key="*this"> <view class="classname"> <text class="log-item">{{index + 1}}. {{log}}</text> </view> </block></view>
var util = require('../../utils/util.js')Page({ data: { logs: [ ] }, onLoad: function () { var test = wx.getStorageSync('logs'); var tset1 = test || []; var test3 = function (log) { return util.formatTime(new Date(log)); } var test2 = tset1.map(test3); this.setData({ logs: test2 }) }})
作为一个新手,看不懂demo,就拆分了一下。我是看懂了。
然后就解决了我的问题。
<view class="container log-list"> <block wx:for="{{logs}}" wx:for-item="log" wx:key="*this"> <view class="classname"> <text class="log-item"> {{log.title}}</text> </view> <view class="classname"> <text class="log-item"> {{log.content}}</text> </view> <view class="classname"> <text class="log-item">{{log.url}}</text> </view> </block></view>
Page({ data: { logs: [] }, onLoad: function () { //获取网络数据 var test = [ { "title": "张三", "content": "张三现在不太高兴", "url": "https://chongnb.com/mana/05563814469562242.jpg" }, { "title": "李四", "content": "李四可能很高兴", "url": "https://chongnb.com/mana/05563814469562242.jpg" }, { "title": "王五", "content": "王五现在不太高兴", "url": "https://chongnb.com/mana/05563814469562242.jpg" } ] //设置数据 this.setData({ logs: test }) }})
阅读全文
0 0
- 小程序for循环对象
- 对for循环做文章的一个小程序
- 小程序for循环中input事件的处理
- for循环小细节
- For循环小例
- java for对象循环
- for循环对象
- for循环angularjs对象
- for循环程序练习
- java程序----for循环
- 用循环语句while或for循环编写一个验证登陆的小程序
- 小程序的循环
- c++for循环小疑惑
- 小99乘法 for循环
- for循环的小技巧
- Python for循环小问题
- for循环结构小案例
- vue v-for 循环对象
- 实用的php文件操作类
- 《剑指offer2》问题8 二叉树的下一个节点 Java实现
- 02-1 Js的基础语法(1)
- ROS学习笔记1
- 编译、链接学习笔记(三)静态链接
- 小程序for循环对象
- java EE配置文件模版
- (链表进阶)谈一谈各类算法和数据结构的c++实现以及相关操作的复杂度(三)
- KHL 005 11-计算机-本职-前台 CSS3 动画
- 一个给 Java 程序员用的 Api 文档生成工具
- JAVA流程控制习题
- vim
- spark读取kafka两种方式的区别
- 模拟退火算法的 C++ 实现