老司机三级_天天干天天操天天爽_女人被爽到娇喘呻吟视频_久久国产精品99久久久大便 - 亚洲日本系列

toast顯示消息提示

本文編輯: DevelopeWhite DevelopeWhite瀏覽 6220 版權所有,嚴禁轉載

組件說明:

Toast是當用戶點擊某些組件時彈出來來的提示消息。Toast會幫助你創建和顯示這些消息。Toast是一種簡易的消息提示框。當視圖顯示給用戶,在應用程序中顯示為浮動。小程序即將廢棄Toast組件,故這里介紹Toast的API:wx.showToast

組件用法:


wxml

<!--index.wxml-->
<view class="content">
  <text class="showfunc">Toast功能</text>
  <view class="con-button">
    <button class="button-left" bindtap="showToast">展示Toast</button>
    <button class="button-right" bindtap="hideToast">隱藏Toast</button>
  </view>
</view>

js

Page({
  showToast:function(){
    var that=this;
    wx.showToast({
      title: '成功',
      icon: 'success',
      duration: 2000,
      success: that.flySuccess,
      fail:that.flyFail,
      complete:that.flyComplete
    })
  },

  hideToast:function(){
    var that=this;
    wx.showToast({
      title: '加載中',
      icon: 'loading',
      duration: 10000,
      success: that.loadingSuccess,
      fail:that.loadingFail,
      complete:that.loadingComplete
    });

    setTimeout(function(){
      wx.hideToast()
    },2000)
  },

  flySuccess:function(e){
    console.log(e);
    console.log("起飛成功!");
  },
  flyFail:function(e){
    console.log(e);
    console.log("起飛失敗!")
  },
  flyComplete:function(e){
    console.log(e);
    console.log("起飛結束!")
  },
  loadingSuccess:function(e){
    console.log(e);
    console.log("加載成功!");
  },
  loadingFail:function(e){
    console.log(e);
    console.log("加載失敗!")
  },
  loadingComplete:function(e){
    console.log(e);
    console.log("加載結束!")
  }
})

wxss

/**index.wxss**/
.con-button{
  display: flex;
  flex-direction: row;
  padding-top: 10%;
}

.showfunc{
  padding-top:10%;
  display: block;
  text-align: center;
  color: green;
}

主要參數:

參數 類型 是否必填 參數描述
title String 該提示框提示的內容
icon String 該提示框的圖標,只支持”success”、”loading”
duration Number 提示的延遲時間,單位毫秒,默認:1500, 最大為10000
success Function 該接口調用成功的回調函數
fail Function 接口調用失敗的回調函數
complete Function 接口調用結束的回調函數(調用成功、失敗都會執行)
如有技術問題或對本文有反饋,請加入QQ群:
微信小程序實戰5營: 微信小程序Club實戰5營