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

小程序模板網

微信小程序 - toptip效果

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

在Page頂部下滑一個提示條 , 代碼見 /mixins/UIComponent.js ,其中的self 可以認為是微信小程序的Page對象

效果: 默認2秒展示,上移動畫隱藏

 

				
  1. /**
  2. * 展示頂部 tip , 多次快速調用,會覆蓋前次展示
  3. */
  4. UIComponent.showToptip = function (opt = {}) {
  5. var self = this;
  6. if (self.uiComponent_topTip_timer) { //如果之前有timer,那么取消后重新創建
  7. clearTimeout(self.uiComponent_topTip_timer);
  8. }
  9. if (typeof opt == "string") {
  10. opt = {
  11. content: opt
  12. }
  13. }
  14. //默認參數,也是外部參考的傳參
  15. var defaultOptions = {
  16. show: false, //是否顯示,默認不顯示
  17. style: "", //外部傳入的自定義樣式,比如字體,背景色
  18. content: "操作成功", //默認的內容
  19. duration: 2000 //顯示延遲幾秒
  20. };
  21. let app = getApp();
  22. opt = app.util.extend(defaultOptions, opt);
  23. self.setData({
  24. 'uiComponent.toptip.show': true,
  25. 'uiComponent.toptip.style': opt.style,
  26. "uiComponent.toptip.content": opt.content
  27. });
  28. self.uiComponent_topTip_timer = setTimeout(() => {
  29. self.setData({
  30. 'uiComponent.toptip.show': false
  31. });
  32. }, opt.duration);
  33. }
 

				
  1. <view class="uiComponent uiComponent_toptip uiComponent_toptip_{{uiComponent.toptip.show &&'active'}}"
  2. style="{{uiComponent.toptip.style}}"
  3.  
  4. >{{uiComponent.toptip.content}} </view>
 

				
  1. .uiComponent {
  2. z-index: 110;
  3. }
  4. /* toptip 頂部提示條效果 */
  5. .uiComponent_toptip {
  6. width: 100%;
  7. display: block;
  8. top:-50px;
  9. position: fixed; text-align: center;
  10. line-height: 2.3;
  11. font-size: 30rpx;
  12. transition: all .2s linear ;
  13. }
  14.  
  15. .uiComponent_toptip_active {
  16. top:0;
  17. transition: all .3s linear ;
  18. min-height: 32px;
  19. color: #fff;
  20. background-color: rgba(0,0,0,.8);
  21. }


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