Home > WeChat Applet > Mini Program Development > Basics of Mini Program Development - Logs Page Analysis (6)

Basics of Mini Program Development - Logs Page Analysis (6)

Y2J
Release: 2017-04-25 09:35:18
Original
3593 people have browsed it

In the previous tutorial, the index page was parsed. This article will parse the logs page.

The old rule is to show the picture first

Basics of Mini Program Development - Logs Page Analysis (6)

logs page

This page contains the return button (used to return to the index page), page title and program startup log list.
Compared with the index page, the logs page has an additional logs.json file to configure the content of the page title

{
    "navigationBarTitleText": "查看启动日志"
}
Copy after login

For more configuration items, please refer to the configuration applet

<!--logs.wxml-->
<view class="container log-list">
  <block wx:for="{{logs}}" wx:for-item="log">
    <text class="log-item">{{index + 1}}. {{log}}</text>
  </block>
</view>
Copy after login

In logs In .wxml, three tags are defined, namely view, block and text. The view tag is the container, the block is used to bind the logs array, and the text tag is used to display each log. wx:for and wx:for-item are the list binding syntax provided by the mini program box. For more details, please refer to List Rendering

//logs.js
var util = require(&#39;../../utils/util.js&#39;)
Page({
  data: {
    logs: []
  },
  onLoad: function () {
    this.setData({
      logs: (wx.getStorageSync(&#39;logs&#39;) || []).map(function (log) {
        return util.formatTime(new Date(log))
      })
    })
  }
})
Copy after login

logs.js defines the logs array and caches it locally in the onLoad method. Obtain the program startup time data, and then call the map method of the array to format the time into a string

.log-list {
  display: flex;
  flex-direction: column;
  padding: 40rpx;
}
.log-item {
  margin: 10rpx;
}
Copy after login

Finally, it is still logs.wxss to control the page style.

At this point, the parsing part of the default generation program is over. This analysis process is to have an overall understanding of the WeChat applet, so many places are not in depth. In the following tutorials, I will continue to explain various aspects of WeChat applet development.

The above is the detailed content of Basics of Mini Program Development - Logs Page Analysis (6). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template