Home Web Front-end JS Tutorial Ionic implementation of verification code countdown example sharing

Ionic implementation of verification code countdown example sharing

Feb 09, 2018 am 10:18 AM
ionic Countdown Example

When users register, many apps nowadays choose to bind mobile phone numbers for registration. This is a very good idea, which is convenient for users to operate and also very convenient to comply with the real-name system. When designing the button, you need to let It is displayed next to the input verification code, and after the user clicks it, it starts counting down and turns the button into an unclickable effect. This article mainly introduces the implementation of verification code countdown in Ionic learning diary. I hope it can help you.

This diary only involves the files under one page, including html, ts and scss (my page name is reg, which can be adjusted according to your specific situation)

Define the information that can be obtained in html in reg.ts


1

2

3

4

5

6

//验证码倒计时

 verifyCode: any = {

  verifyCodeTips: "获取验证码",

  countdown: 60,

  disable: true

 }

Copy after login

reg.html design layout

The above picture is I designed it myself, here I only take the key code

Copy code The code is as follows:



Click the event getCode(), whether it is possible to set [disabled] Click the button and use the boolean value to judge. The main displayed content is verifyCode.verifyCodeTips, which is the text information and the countdown that needs to be implemented later

reg.ts adding method and countdown processing

When the button is clicked, the getCode() method will be triggered. After triggering the method, first change the value of disable to false, set the button to be unclickable, and then trigger the settime method


1

2

3

4

5

getCode() {

 //点击按钮后开始倒计时

 this.verifyCode.disable = false;

 this.settime();

}

Copy after login

settime() specifically implements the countdown function


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

//倒计时

 settime() {

  if (this.verifyCode.countdown == 1) {

   this.verifyCode.countdown = 60;

   this.verifyCode.verifyCodeTips = "获取验证码";

   this.verifyCode.disable = true;

   return;

  } else {

   this.verifyCode.countdown--;

  }

  this.verifyCode.verifyCodeTips = "重新获取"+this.verifyCode.countdown+"秒";

  setTimeout(() => {

   this.verifyCode.verifyCodeTips = "重新获取"+this.verifyCode.countdown+"秒";

   this.settime();

  }, 1000);

 }

Copy after login

Use the counter to decrement by 1 every 1 second. For a simple countdown function, the important thing is to determine whether the counter is 1. When After it is 1, re-initialize the 3 information of verifyCode

Simple implementation method of mobile phone registration to send verification code countdown

Use Angular.js to obtain verification code countdown 60 seconds button method

Send verification code countdown function when mobile phone registration


The above is the detailed content of Ionic implementation of verification code countdown example sharing. 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 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

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)

How to write a simple countdown program in C++? How to write a simple countdown program in C++? Nov 03, 2023 pm 01:39 PM

C++ is a widely used programming language that is very convenient and practical in writing countdown programs. Countdown program is a common application that can provide us with very precise time calculation and countdown functions. This article will introduce how to use C++ to write a simple countdown program. The key to implementing a countdown program is to use a timer to calculate the passage of time. In C++, we can use the functions in the time.h header file to implement the timer function. The following is the code for a simple countdown program

SVM examples in Python SVM examples in Python Jun 11, 2023 pm 08:42 PM

Support Vector Machine (SVM) in Python is a powerful supervised learning algorithm that can be used to solve classification and regression problems. SVM performs well when dealing with high-dimensional data and non-linear problems, and is widely used in data mining, image classification, text classification, bioinformatics and other fields. In this article, we will introduce an example of using SVM for classification in Python. We will use the SVM model from the scikit-learn library

How to use Vue to implement button countdown effects How to use Vue to implement button countdown effects Sep 21, 2023 pm 02:03 PM

How to use Vue to implement button countdown effects With the increasing popularity of web applications, we often need to use some dynamic effects to improve user experience when users interact with the page. Among them, the countdown effect of the button is a very common and practical effect. This article will introduce how to use the Vue framework to implement button countdown effects and give specific code examples. First, we need to create a Vue component that contains a button and countdown function. In Vue, a component is a reusable Vue instance, and a view will

How to cancel the 10-second countdown on booting up Win10? Three ways to cancel the countdown on booting up Win10 How to cancel the 10-second countdown on booting up Win10? Three ways to cancel the countdown on booting up Win10 Feb 29, 2024 pm 07:25 PM

In win10, the boot countdown is enabled by default. When we turn on the computer, we will see a countdown interface, usually a 10-second countdown. Within this time, we can choose whether to continue booting or perform some other operations. Although the boot countdown brings some convenience to our system, it may also cause trouble in some cases. I want to cancel the display, but I don’t know how to do it. This article brings you how to cancel the countdown of several seconds after booting up Win10. Understand the win10 boot countdown. In win10, the boot countdown is enabled by default. When we turn on the computer, we will see a countdown interface, usually a 10-second countdown. Within this time, we can choose whether to continue booting or proceed

How to use CSS to create a countdown effect How to use CSS to create a countdown effect Oct 26, 2023 am 10:36 AM

How to use CSS to create a countdown effect. The countdown effect is a common function in web development. It can provide users with a dynamic effect of countdown and give people a sense of urgency and expectation. This article will introduce how to use CSS to achieve the countdown effect, and give detailed implementation steps and code examples. The implementation steps are as follows: Step 1: HTML structure construction First, create a div container in HTML to wrap the countdown content. For example: <divclass="countd

Learn best practice examples of pointer conversion in Golang Learn best practice examples of pointer conversion in Golang Feb 24, 2024 pm 03:51 PM

Golang is a powerful and efficient programming language that can be used to develop various applications and services. In Golang, pointers are a very important concept, which can help us operate data more flexibly and efficiently. Pointer conversion refers to the process of pointer operations between different types. This article will use specific examples to learn the best practices of pointer conversion in Golang. 1. Basic concepts In Golang, each variable has an address, and the address is the location of the variable in memory.

VUE3 Getting Started Example: Making a Simple Video Player VUE3 Getting Started Example: Making a Simple Video Player Jun 15, 2023 pm 09:42 PM

As the new generation of front-end frameworks continues to emerge, VUE3 is loved as a fast, flexible, and easy-to-use front-end framework. Next, let's learn the basics of VUE3 and make a simple video player. 1. Install VUE3 First, we need to install VUE3 locally. Open the command line tool and execute the following command: npminstallvue@next Then, create a new HTML file and introduce VUE3: <!doctypehtml>

VAE algorithm example in Python VAE algorithm example in Python Jun 11, 2023 pm 07:58 PM

VAE is a generative model, its full name is VariationalAutoencoder, which is translated into Chinese as variational autoencoder. It is an unsupervised learning algorithm that can be used to generate new data, such as images, audio, text, etc. Compared with ordinary autoencoders, VAEs are more flexible and powerful and can generate more complex and realistic data. Python is one of the most widely used programming languages ​​and one of the main tools for deep learning. In Python, there are many excellent machine learning and deep

See all articles