This article mainly introduces the relevant information on the detailed examples of self-made widgets for WeChat mini programs. The self-made widgets can be used in projects. Friends in need can refer to
WeChat mini program production Widget
Some common things in our daily life can be encapsulated into components and then used on various pages. For small programs, we can also encapsulate some public things we need.
Here we explain a small plug-in.
As shown in the picture above, a small plug-in, click to expand, click to close, the button will close.
WXML (APP.wxml) of the page
<template name="widget-dialog-iconList"> <view class="com-widget-iconList {{close==1?'hideImg':''}}" style="display:flex;flex-direction:row;"> <view style="display:flex;flex-direction:row;"> <view class="left-icon" style="display:flex;flex-direction:row;"> <view class="left-circle"></view> <image class="icon1" src="http://m.dev.vd.cn/static/xcx/v1/goo/md_logo.png"></image> </view> <view class="middle_icon " style="display:flex;flex-direction:row;"> <navigator url="../tua/home"> <view class="section1"> <view><image class="icon2" src="http://m.dev.vd.cn/static/xcx/v1/goo/firsticon.png"></image></view> <view class="text">首页</view> </view> </navigator> <navigator url="../ord/list"> <view class="section2"> <view><image class="icon2" src="http://m.dev.vd.cn/static/xcx/v1/goo/orderIcon.png"></image></view> <view class="text">订单</view> </view> </navigator> <navigator url="../usr/center"> <view class="section3"> <view><image class="icon3" src="http://m.dev.vd.cn/static/xcx/v1/goo/myself.png"></image></view> <view class="text">我的</view> </view> </navigator> <view class="right-icon" style="display:flex;flex-direction:row;"> <image class="iconright" src="http://m.dev.vd.cn/static/xcx/v1/goo/delAllIcon.png" bindtap="closeAllIcon"></image> </view> </view> </view> </view> <view class="iconOnly {{close==0?'hideImg':''}}"> <image class="iconOnlyPic" src="http://m.dev.vd.cn/static/xcx/v1/goo/md_logo.png" bindtap="showAllIcon"></image> </view> </template>
This is mainly the surface display effect of the plug-in. Just write it in the tag.
JS (APP.js) of the page
var iconList = {}; //设置一个对象名字存放数据 iconList.Wdg= { //存放要给VIEW层的页面数据,closeAllIcon ,showAllIcon 是对应的方法 data: { index: 0, close:0 }, closeAllIcon: function(e){ this.setData({ close:1 }) }, showAllIcon :function(e){ this.setData({ close:0 }) } }; module.exports=iconList //将接口的进行暴露,方便在外面调用
The next step is to encapsulate it and how to use it .
In the required WXML page:
Introduce the Jin page through , and then use it through
<template is="widget-dialog-iconList" data="{{你要传到页面的数据}}"></template>
.
In the required WXML page:
Introduce the corresponding JS through var iconList = require('../wdg/iconList');
var util= require('../../util/util'); var Page = new util.Page({ Wdgs: [iconList.Wdg] });
Introduce the corresponding files.
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
About WeChat Mini Program
Introduction to welcome interface development
Implementation of pull-up loading and pull-down refresh of WeChat applet list
The above is the detailed content of WeChat Mini Program Make your own widgets. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于微信小程序的相关问题,其中主要介绍了关于基础架构原理的相关内容,其中包括了宿主环境、执行环境、小程序整体架构、运行机制、更新机制、数据通信机制等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于微信小程序的相关知识,其中主要介绍了关于云服务的配置详解,包括了创建使用云开发项目、搭建云环境、测试云服务等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于微信小程序的相关知识,其中主要介绍了关于富文本编辑器的实战示例,包括了创建发布页面、实现基本布局、实现编辑区操作栏的功能等内容,下面一起来看一下,希望对大家有帮助。

西安坐地铁用的小程序为“乘车码”。使用方法:1、打开手机微信客户端,点击“发现”中的“小程序”;2、在搜索栏中输入“乘车码”进行搜索;3、直接定位城市西安,或者搜索西安,点击“西安地铁乘车码”选项的“去乘车”按钮;4、根据腾讯官方提示进行授权,开通“乘车码”业务即可利用该小程序提供的二维码来支付乘车了。

本篇文章给大家带来了关于微信小程序的相关知识,其中主要介绍了怎么实现小程序授权登录功能的相关内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于微信小程序的相关问题,其中主要介绍了关于开发工具介绍的相关内容,包括了下载开发工具以及编辑器总结等内容,下面一起来看一下,希望对大家有帮助。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

WebStorm Mac version
Useful JavaScript development tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use
