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

效果图:

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

自定义代码:
javascript 复制代码
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;
}
相关推荐
吃杠碰小鸡21 分钟前
高中数学-数列-导数证明
前端·数学·算法
kingwebo'sZone27 分钟前
C#使用Aspose.Words把 word转成图片
前端·c#·word
xjt_09011 小时前
基于 Vue 3 构建企业级 Web Components 组件库
前端·javascript·vue.js
游戏开发爱好者81 小时前
日常开发与测试的 App 测试方法、查看设备状态、实时日志、应用数据
android·ios·小程序·https·uni-app·iphone·webview
我是伪码农1 小时前
Vue 2.3
前端·javascript·vue.js
夜郎king1 小时前
HTML5 SVG 实现日出日落动画与实时天气可视化
前端·html5·svg 日出日落
夏幻灵2 小时前
HTML5里最常用的十大标签
前端·html·html5
Mr Xu_3 小时前
Vue 3 中 watch 的使用详解:监听响应式数据变化的利器
前端·javascript·vue.js
未来龙皇小蓝3 小时前
RBAC前端架构-01:项目初始化
前端·架构
程序员agions3 小时前
2026年,微前端终于“死“了
前端·状态模式