Home  >  Article  >  WeChat Applet  >  Implementation code of pop-up box of mini program popupwindow

Implementation code of pop-up box of mini program popupwindow

不言
不言Original
2018-09-06 09:49:393544browse

The content of this article is about the implementation code of the popupwindow pop-up box of the mini program. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Pop up above

Implementation code of pop-up box of mini program popupwindow

##wxml

<view class="zan-dialog {{ showDialog ? &#39;zan-dialog--show&#39; : &#39;&#39; }}">
  <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
    });

  },

})

Pop up below

wxml

  <view class="zan-dialog {{ showDialog ? &#39;zan-dialog--show&#39; : &#39;&#39; }}">
    <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
    });

  },

})

Related recommendations:

In the WeChat applet Add a pop-up dialog box

WeChat applet uses modal component to pop-up dialog box example sharing

The above is the detailed content of Implementation code of pop-up box of mini program popupwindow. For more information, please follow other related articles on 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