网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網

微信小程序--自定義Toast、延時執行

發布時間:2018-04-20 11:08 所屬欄目:小程序開發教程

Toast樣式可以根據需求自定義,本例中是圓形

 

				
  1. [html] view plain copy
  2. <!--按鈕-->
  3. <view class="btn" bindtap="btn_toast">自定義Toast</view>
  4. <!--以下為toast顯示的內容 opacity為透明度-->
  5. <view class="toast_box" style="opacity:{{0.9}}" wx:if="{{isShowToast}}">
  6. {{toastText}}
  7. </view>
  8. <view class="toast_box" style="opacity:{{0.9}}" wx:if="{{isShowToast}}">
  9. {{toastText1}}
  10. </view>
 

				
  1. [css] view plain copy
  2. Page {
  3. background: #f9f9f9;
  4. }
  5. /*按鈕*/
  6. .btn {
  7. width: 20%;
  8. margin-left: 38%;
  9. margin-top: 100rpx;
  10. text-align: center;
  11. border-radius: 10rpx;
  12. border: 10px solid #f00;
  13. background: #f00;
  14. color: #fff;
  15. font-size: 22rpx;
  16. }
  17. /*toast*/
  18. .toast_box {
  19. width: 30%;
  20. height: 221rpx;
  21. margin-top: 60rpx;
  22. margin-left: 35%;
  23. text-align: center;
  24. border-radius: 166rpx;
  25. background: #f00;
  26. color: #fff;
  27. font-size: 32rpx;
  28. line-height: 220rpx;
  29. }
 

				
  1. [javascript] view plain copy
  2. Page({
  3.  
  4. /**
  5. * 頁面的初始數據
  6. */
  7. data: {
  8. //toast默認不顯示
  9. isShowToast: false
  10. },
  11. showToast: function () {
  12. var _this = this;
  13. // toast時間
  14. _this.data.count = parseInt(_this.data.count) ? parseInt(_this.data.count) : 1000;
  15. // 顯示toast
  16. _this.setData({
  17. isShowToast: true,
  18. });
  19. // 定時器關閉
  20. setTimeout(function () {
  21. _this.setData({
  22. isShowToast: false
  23. });
  24. }, _this.data.count);
  25. },
  26. /* 點擊按鈕 */
  27. btn_toast: function () {
  28. console.log("點擊了按鈕")
  29. //設置toast時間,toast內容
  30. this.setData({
  31. count: 1500,
  32. toastText: '自定義',
  33. toastText1: 'Toast'
  34. });
  35. this.showToast();
  36. },
  37. /**
  38. * 生命周期函數--監聽頁面加載
  39. */
  40. onLoad: function (options) {
  41.  
  42. },})

延時執行:

 

				
  1. [javascript] view plain copy
  2. setTimeout(function () {
  3. //要延時執行的代碼
  4. }, 1000) //延遲時間 這里是1秒  


易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/23785.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×