In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "WeChat Mini Programs how to achieve custom toast" related knowledge, editor through the actual case to show you the operation process, the method of operation is simple and fast, practical, I hope that this "WeChat Mini Programs how to achieve custom toast" article can help you solve the problem.
Wechat officially defaults to toast.
Toast is the most common. Almost every App has such special effects. Let's first take a look at the toast effect that comes with Mini Program.
Wechat comes with toast:
Js file:
Wx.showToast ({title: 'success', icon: 'success', duration: 2000})
It's super easy to use, but there are several problems with the official Mini Program:
Only success and loading icon can be displayed.
And icon cannot be removed.
Duration up to 10 seconds
II. Custom toast
Our most common toast is at the bottom, and the height is relatively small.
Let's first look at the effect:
It seems simple, but it is not easy to implement. How to achieve:
1) create a common template template file for toast, because toast is required for each page
{{title}}
2) JS has the following main uses
Core code:
Let pages = getCurrentPages (); let curPage = pages [pages.length-1]
This code is the core, getCurrentPages (). Length-1 indicates that you can get the page of the current page, and only when you get the page can you bind the data of the current page to toast through page.setData.
Core code:
Let animation = wx.createAnimation (); animation.opacity (1). Step ()
This code has a slow animation effect when toast disappears.
This is the end of the introduction of "how to achieve custom toast by WeChat Mini Programs". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.