国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home WeChat Applet Mini Program Development WeChat Mini Program Modular Detailed Introduction

WeChat Mini Program Modular Detailed Introduction

Feb 17, 2017 am 10:31 AM

This article mainly introduces relevant information about the detailed introduction of the modularization of WeChat mini programs. Friends who need it can refer to it

Modularization is to extract some common things and put them into a file. module.exports to expose interfaces. When we first created the project, there was a util.js file that was modularized.

 /**
 * 處理具體業(yè)務(wù)邏輯
 */
function formatTime(date) {
 //獲取年月日
 var year = date.getFullYear()
 var month = date.getMonth() + 1
 var day = date.getDate()

 //獲取時(shí)分秒
 var hour = date.getHours()
 var minute = date.getMinutes()
 var second = date.getSeconds();

 //格式化日期
 return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

function formatNumber(n) {
 n = n.toString()
 return n[1] ? n : '0' + n
}

/**
 * 模塊化導(dǎo)出暴露接口
 */
module.exports = {
 formatTime: formatTime
}

Usage method:

//導(dǎo)入模塊化方式
var util = require('../../utils/util.js')
Page({
 data: {
 logs: []
 },
 onLoad: function () {
 this.setData({
 logs: (wx.getStorageSync('logs') || []).map(function (log) {
 // 通過暴露的接口調(diào)用模塊化方法
 return util.formatTime(new Date(log))
 })
 })
 }
})

For more detailed introduction to the modularization of WeChat mini programs and related articles, please pay attention to the PHP Chinese website!

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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)