During the development process, we often encapsulate some common functional code or effects into components one by one, and then call them on the pages needed. For the development of small programs, we can also encapsulate some public components. During the development process, we often encapsulate some common functional code or effects into components one by one, and then call them on the pages needed.
For the development of small programs, we can also encapsulate some public components.
Next we will explain a menu that can be expanded by clicking the icon.
WXML (APP. wxml) of the page)
Homepage
Order
My
This is mainly the display effect of the pressure surface of the plug-in, which can be written in the label.
Page JS (APP. js)
Var iconList ={}; // Set an object name to store data iconList. wdg = {// The page data to be stored for the VIEW layer. closeAllIcon and showAllIcon are the corresponding methods: data: {index: 0, close: 0}, closeAllIcon: function (e) {this. setData ({close: 1})}, showAllIcon: function (e) {this. setData ({close: 0}) }}; module. exports = iconList // expose the interface for convenient calling outside
The package is encapsulated, so how to use it.
On the required WXML page:
By introducing the catty page
.
On the required WXML page:
Use var iconList = require ('../wdg/iconlist') to introduce the corresponding JS
var util= require('../../util/util');var Page = new util.Page({ Wdgs: [iconList.Wdg]});
Introduce the corresponding file.
For more articles on how to encapsulate and create public components of applets, please follow the PHP Chinese network!