WeChat applet wx. showToast (OBJECT) interpretation and use example

Source: Internet
Author: User
Wx. showToast (OBJECT) is an API provided to display a message prompt box. The following is an official document description: wx. showToast (OBJECT) is an API provided to display a message prompt box.
The following is an official document description:

Although there are only two icons, this "success" icon can be used in many scenarios, however, if you need to wait for the user, you need to use the "loading" icon.

The following is the official sample code:

Wx. showToast ({title: 'success', icon: 'success', duration: 2000 })

The following shows how to use this API. first, open the WEB developer tool, create a quick project, delete unused content on the home page, and retain it, as shown in.

Add the navigator navigation to the default log page.

The WXML code of the index page is as follows:

   
  Login
 
  
 
   
  View more
 

The js code of the index page is as follows:

Logbtn: function () {wx. showToast ({title: 'login successfully', icon: 'Success ', duration: 1200})}, morebtn: function () {wx. showToast ({title: 'loading ', icon: 'Loading', duration: 1200 })},

The two buttons are too close. we insert a View tag in the middle to make the buttons have more spacing, as shown in the following code:

  
 

The page rendering style is as follows:

Through the above demonstration, you can know the effect of this API and the applicable scenarios, and make it easier for you to directly call the official API when needed.

For more information about how to interpret the wx. showToast (OBJECT) of small programs and related articles on use examples, see PHP Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.