Home Web Front-end JS Tutorial How to use toast message dialog box in WeChat applet

How to use toast message dialog box in WeChat applet

Jun 21, 2018 pm 05:47 PM
toast password WeChat applet hint username enter

This article mainly introduces the function of using the toast message dialog box in the WeChat applet to prompt the user to forget to enter the user name or password. It analyzes in detail the relevant operating skills of the toast component to implement the message prompt function in the form of examples, and comes with source code for readers to download. For reference, friends in need can refer to

This article describes the example of the WeChat applet using the toast message dialog box to prompt the user to forget to enter the user name or password. Share it with everyone for your reference, as follows:

Key code

① index.wxml

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<form bindsubmit="formBindsubmit" bindreset="formReset">

 <view style="display:flex;">

  <label>用户名:</label>

  <input name="userName" placeholder="请输入用户名!" />

 </view>

 <view style="display:flex;">

  <label>密码:</label>

  <input name="psw" placeholder="请输入密码!" password="true" />

 </view>

 <view style="display:flex;margin-top:30px;">

  <button style="width:30%;" formType="submit" >登录</button>

  <button style="width:30%" formType="reset" >重置</button>

 </view>

</form>

<view>{{userName}}</view>

<view>{{psw}}</view>

<toast duration="2000" hidden="{{toastHidden}}" bindchange="toastBindChange">用户名或密码不能为空!</toast>

Copy after login

② index.js

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

Page({

 data:{

  // text:"这是一个页面"

  toastHidden:true,

  userName:'',

  psw:''

 },

 formBindsubmit:function(e){

  if(e.detail.value.userName.length==0||e.detail.value.psw.length==0){

   this.setData({

    toastHidden:!this.data.toastHidden

   })

  }else{

   this.setData({

    tip:'',

    userName:'用户名:'+e.detail.value.userName,

    psw:'密码:'+e.detail.value.psw

   })

  }

 },

 formReset:function(){

  this.setData({

   userName:'',

   psw:''

  })

 },

 toastBindChange:function(){

  this.setData({

    toastHidden:!this.data.toastHidden

  })

 }

})

Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to build a universal data simulation framework for the front end (detailed tutorial)

How to implement flux on knockoutjs

How to implement seamless scrolling components using vue

About the difficulty of JavaScript array operations (detailed tutorial)

How to implement the like function in WeChat mini program

The above is the detailed content of How to use toast message dialog box in WeChat applet. For more information, please follow other related articles on 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 Article Tags

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)

What should I do if Google Chrome prompts that the content of this tab is being shared? What should I do if Google Chrome prompts that the content of this tab is being shared? Mar 13, 2024 pm 05:00 PM

What should I do if Google Chrome prompts that the content of this tab is being shared?

How to solve the problem that Windows 11 prompts you to enter the administrator username and password to continue? How to solve the problem that Windows 11 prompts you to enter the administrator username and password to continue? Apr 11, 2024 am 09:10 AM

How to solve the problem that Windows 11 prompts you to enter the administrator username and password to continue?

Windows input encounters hang or high memory usage [Fix] Windows input encounters hang or high memory usage [Fix] Feb 19, 2024 pm 10:48 PM

Windows input encounters hang or high memory usage [Fix]

How to set router WiFi password using mobile phone (using mobile phone as tool) How to set router WiFi password using mobile phone (using mobile phone as tool) Apr 24, 2024 pm 06:04 PM

How to set router WiFi password using mobile phone (using mobile phone as tool)

Tutorial on changing wifi password on mobile phone (simple operation) Tutorial on changing wifi password on mobile phone (simple operation) Apr 26, 2024 pm 06:25 PM

Tutorial on changing wifi password on mobile phone (simple operation)

Incorrect password, beware BitLocker warning Incorrect password, beware BitLocker warning Mar 26, 2024 am 09:41 AM

Incorrect password, beware BitLocker warning

How to switch between dual systems and reset password on Huawei mobile phone How to switch between dual systems and reset password on Huawei mobile phone Feb 19, 2024 am 09:05 AM

How to switch between dual systems and reset password on Huawei mobile phone

How to use Passkey for your Microsoft account How to use Passkey for your Microsoft account Feb 19, 2024 am 11:03 AM

How to use Passkey for your Microsoft account

See all articles