Home >WeChat Applet >Mini Program Development >Detailed explanation and example code of WeChat mini program toast

Detailed explanation and example code of WeChat mini program toast

高洛峰
高洛峰Original
2017-02-13 10:44:172011browse

This article mainly introduces the detailed explanation and example code of WeChat Mini Program toast. Friends in need can refer to the

WeChat Mini Program toast

Message Prompt box


##Property nameTypeDefault valueDescriptiondurationFloat1500 After hidden is set to false, bindchange is triggered Delay, unit millisecondhiddenBooleanfalseWhether to hidebindchangeEventHandleTriggered after duration delay##Sample code:


<view class="body-view">
 <toast hidden="{{toast1Hidden}}" bindchange="toast1Change">
  默认
 </toast>
 <button type="default" bindtap="toast1Tap">点击弹出默认toast</button>
</view>
<view class="body-view">
 <toast hidden="{{toast2Hidden}}" duration="3000" bindchange="toast2Change">
  设置duration
 </toast>
 <button type="default" bindtap="toast2Tap">点击弹出设置duration的toast</button>
</view>

var toastNum = 2
var pageData = {}
pageData.data = {}
for (var i = 0; i <= toastNum; ++i) {
 pageData.data[&#39;toast&#39;+i+&#39;Hidden&#39;] = true;
 (function (index) {
 pageData[&#39;toast&#39;+index+&#39;Change&#39;] = function(e) {
  var obj = {}
  obj[&#39;toast&#39;+index+&#39;Hidden&#39;] = true;
  this.setData(obj)
 }
 pageData[&#39;toast&#39;+index+&#39;Tap&#39;] = function(e) {
  var obj = {}
  obj[&#39;toast&#39;+index+&#39;Hidden&#39;] = false
  this.setData(obj)
 }
 })(i)
}
Page(pageData)

微信小程序 toast 详解及实例代码 Thank you for reading, I hope it can help everyone, thank you everyone Support this site!

For more detailed explanations and example codes of WeChat mini program toast, please pay attention to the PHP Chinese website!

Statement:
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