search
HomeWeChat AppletWeChat DevelopmentUsage examples of toast prompt plug-in developed by WeChat

This article mainly introduces you to the relevant information of the toast prompt plug-in for WeChat applet development. The article introduces it in detail through the example code, which has certain reference and learning value for everyone. Friends who need it can take a look below. Bar.

Preface

WeChat updated the version on March 28. ShowToast can modify the default icon through the image parameter, and the maximum time has also been cancelled.

The above two updates are very useful, but the icon still cannot be removed. The display form is a bit simple and cannot be customized. More functions may be added in subsequent updates. Let’s take a look at the details of this article:

Download the file below the article and place it in the root directory.

Then introduce js in app.js and add it to App, as follows:


var wxToast = require('toast/toast.js')
App({
 wxToast ,
 onLaunch: function () {}
})

In app. Add the following css to wxss:


##

.wxToast_mask{width:100%;height:100%;position:fixed;left:0px;top:0px;z-index:10000;background:rgba(0,0,0,0);opacity:0;display:none}.wxToast_show{display:block}.wxToast_content{max-width:80%;min-width:90px;position:absolute;left:50%;top:20%;transform:translate3d(-50%,0,0);padding:15px;color:#fff;font-size:17px;text-align:center;border-radius:5px;background:rgba(0,0,0,.8)}.wxToast_img{width:55px;height:55px;display:block;margin:0 auto 8px auto}

Then add the following content to page xxx.wxml:


<import src="../../toast/toast.wxml"/>
<template is="wxToast" data="{{...wxToastConfig}}"></template>

Finally It can be called in page xxx.js.


var app = getApp(); //wxToast挂载在app下面,所以必须先获取app
Page({
 toast: {
 //调用
 app.wxToast({
  title : &#39;加载中&#39;
 })
 },
 onLoad : function( ){}
})

More methods:


app.wxToast({
 title : &#39;验证码错误&#39;, //标题,不写默认正在加载
 img : &#39;../../images/cc.png&#39;, //icon路径,不写不显示
 imgClass : &#39;images&#39;, //icon添加class类名
 contentClass : &#39;content&#39;, //内容添加class类名
 duration : 3000, //延时关闭,默认2000
 tapClose : false, //点击关闭,默认false
 show : function(){ //显示函数
 console.log(&#39;显示啦&#39;)
 },
 hide : function(){ //关闭函数
 console.log(&#39;消失啦&#39;)
 }
});


app.wxToast(false); //如果需要隐藏,参数设置为false即可。
setTimeout(function(){
 app.wxToast(false);
},3000)

Click here to download the file

The above is the detailed content of Usage examples of toast prompt plug-in developed by WeChat. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

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.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor