Explanation of WeChat mini-program development-wx. showToast (OBJECT) usage, wx. showtoastobject

Source: Internet
Author: User

Explanation of small program development-wx. showToast (OBJECT) usage, wx. showtoastobject

Wx. showToast API is used to display the message prompt box.

Let's take a look at the official documentation:

Note: Only "success" and "loading" are supported for the icons"

Sample Code:

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

Next we will demonstrate how to use it. First open the web Developer tool, create a quick project, delete useless content on the home page, and retain the following parts.

 

Add two buttons and add click events for colleagues. Add the navigator navigation to the default log page. The Code is as follows:

<Navigator url = ".. /logs "> <button type =" primary "bindtap =" logbtn "> login </button> </navigator> <view class =" br "> </view> <navigator url = ".. /logs "> <button type =" primary "bindtap =" morebtn "> View More </button> </navigator>

The index. js code is as follows:

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

To make the test more intuitive, We can insert a view tag in the two buttons so that there is a gap between the two buttons. The wxml code is as follows:

 <view class="br"> </view>

The wxss file code is as follows:

.br{ width: 100%; height: 200rpx;}

The final page style is as follows:

Click login:

 

Click to view more:

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.