溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

小程序popupwindow彈出框怎么實現(xiàn)

發(fā)布時間:2021-01-28 10:48:20 來源:億速云 閱讀:211 作者:小新 欄目:移動開發(fā)

小編給大家分享一下小程序popupwindow彈出框怎么實現(xiàn),希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

小程序popupwindow彈出框的實現(xiàn)代碼

在上方彈出

小程序popupwindow彈出框怎么實現(xiàn)

wxml

<view class="zan-dialog {{ showDialog ? 'zan-dialog--show' : '' }}">
  <view class="zan-dialog__mask" bindtap="toggleDialog" />
  <view class="zan-dialog__container">
    <view style="padding: 100px 0; text-align: center;">Dialog內容</view>
  </view></view>

wcss

.zan-dialog__mask {
  position: fixed;  
  top: 0;  left: 0;  
  right: 0;  
  bottom: 0;  
  z-index: 10;  
  background: rgba(0, 0, 0, 0.4);  
  display: none;
  }
.zan-dialog__container {
  position: fixed;  
  top: 0;  
  width: 750rpx;  
  background: white;  
  transform: translateY(-150%);  
  transition: all 0.4s ease;  
  z-index: 12;
  }
.zan-dialog--show .zan-dialog__container {
  transform: translateY(0);
  }
.zan-dialog--show .zan-dialog__mask {
  display: block;
  }

js

Page({  data: {    showDialog: false
  },//控制 pop 的打開關閉
  toggleDialog() {
    this.setData({
      showDialog: !this.data.showDialog
    });

  },

})

在下方彈出

wxml

  <view class="zan-dialog {{ showDialog ? 'zan-dialog--show' : '' }}">
    <view class="zan-dialog__mask" bindtap="toggleDialog" />
    <view class="zan-dialog__container">
      <view style="padding: 100px 0; text-align: center;">Dialog內容</view>
    </view>
  </view>

wcss

.zan-dialog__mask {
  position: fixed;  
  top: 0;  
  left: 0;  
  right: 0;  
  bottom: 0;  
  z-index: 10;  
  background: rgba(0, 0, 0, 0.4);  
  display: none;
  }
.zan-dialog__container {
  position: fixed;  
  bottom: 0;  
  width: 750rpx;  
  background: white;  
  transform: translateY(150%);  
  transition: all 0.4s ease;  
  z-index: 12;
  }
.zan-dialog--show .zan-dialog__container {
  transform: translateY(0);
  }
.zan-dialog--show .zan-dialog__mask {
  display: block;
  }

js

Page({  data: {    showDialog: false
  },//控制 pop 的打開關閉
  toggleDialog() {
    this.setData({
      showDialog: !this.data.showDialog
    });

  },

})

看完了這篇文章,相信你對“小程序popupwindow彈出框怎么實現(xiàn)”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI