微信小程序自定义关闭按钮在弹窗下面的效果

效果图:

我之前用vant 的popup的弹窗写,会出现close图标移动到弹窗内容外部不可见。

 自定义代码:
popup.JS

 /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    //自定义弹窗 动态获取屏幕高度
    var that = this;
    wx.getSystemInfo({
      success: (result) => {
        that.setData({
          height: result.windowHeight
        });
      },
    })
  },

closePopup    关闭自定义弹窗
  closePopup(){
    this.setData({
      showCode:false
    })
  }

data(){
 
  height:'',
  showCode:false
 
}


popup.wxml

<view catchtouchmove="{{true}}" class="popup-box" wx:if="{{showCode}}"  bindtap="closePopup"></view>
  <view class="info-center" wx:if="{{showCode}}"  style="top:{{height*0.25}}px;height:{{height*0.4}}px;" >
    <image src="../../static/market/market-tianmu-code.png" class="out-adv" mode="widthFix"></image>  弹窗内容,我比较懒切的图
    <image src="https://xxx.com/close.png" class="close-icon" mode="widthFix" bindtap="closePopup"></image>
 
  </view>
</view>


popup.wxss

/* 蒙层 */
.popup-box{
  position: fixed;
  z-index: 998;
  top: 0;
  background-color: rgba(0, 0, 0, 0.7);
  width: 100%;
  height: 100%;
}
/* 中 */
.info-center{
  position: fixed;
  z-index: 999;
  background-color: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border-radius: 10rpx;
  width: 90%;
  gap: 20px;
  margin-left: 5%;
  margin-right: 5%;
}
.close-icon{
  width: 50rpx;
  height: 50rpx;
  position: absolute;
  bottom: -70rpx;
  left: 50%;
  margin-left: -25rpx;
}

 

相关推荐

  1. 程序实现各类框、定义

    2024-04-12 05:58:09       64 阅读
  2. 程序订阅消息授权事件

    2024-04-12 05:58:09       40 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-12 05:58:09       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-12 05:58:09       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-12 05:58:09       87 阅读
  4. Python语言-面向对象

    2024-04-12 05:58:09       96 阅读

热门阅读

  1. Rust 实现线程安全的 Lock Free 计数器

    2024-04-12 05:58:09       36 阅读
  2. Linux tftp 环境搭建

    2024-04-12 05:58:09       35 阅读
  3. 动态规划专练( 1049.最后一块石头的重量Ⅱ)

    2024-04-12 05:58:09       39 阅读
  4. 创建自定义 通知栏

    2024-04-12 05:58:09       34 阅读
  5. TCP_NODELAY在延迟敏感的场景下适合设置

    2024-04-12 05:58:09       34 阅读