弹窗内容,我比较懒切的图">
当前位置:   article > 正文

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

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

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

 自定义代码:
  1. popup.JS
  2. /**
  3. * 生命周期函数--监听页面初次渲染完成
  4. */
  5. onReady() {
  6. //自定义弹窗 动态获取屏幕高度
  7. var that = this;
  8. wx.getSystemInfo({
  9. success: (result) => {
  10. that.setData({
  11. height: result.windowHeight
  12. });
  13. },
  14. })
  15. },
  16. closePopup 关闭自定义弹窗
  17. closePopup(){
  18. this.setData({
  19. showCode:false
  20. })
  21. }
  22. data(){
  23. height:'',
  24. showCode:false
  25. }
  26. popup.wxml
  27. <view catchtouchmove="{{true}}" class="popup-box" wx:if="{{showCode}}" bindtap="closePopup"></view>
  28. <view class="info-center" wx:if="{{showCode}}" style="top:{{height*0.25}}px;height:{{height*0.4}}px;" >
  29. <image src="../../static/market/market-tianmu-code.png" class="out-adv" mode="widthFix"></image> 弹窗内容,我比较懒切的图
  30. <image src="https://xxx.com/close.png" class="close-icon" mode="widthFix" bindtap="closePopup"></image>
  31. </view>
  32. </view>
  33. popup.wxss
  34. /* 蒙层 */
  35. .popup-box{
  36. position: fixed;
  37. z-index: 998;
  38. top: 0;
  39. background-color: rgba(0, 0, 0, 0.7);
  40. width: 100%;
  41. height: 100%;
  42. }
  43. /* 中 */
  44. .info-center{
  45. position: fixed;
  46. z-index: 999;
  47. background-color: none;
  48. display: flex;
  49. align-items: center;
  50. justify-content: center;
  51. flex-direction: column;
  52. border-radius: 10rpx;
  53. width: 90%;
  54. gap: 20px;
  55. margin-left: 5%;
  56. margin-right: 5%;
  57. }
  58. .close-icon{
  59. width: 50rpx;
  60. height: 50rpx;
  61. position: absolute;
  62. bottom: -70rpx;
  63. left: 50%;
  64. margin-left: -25rpx;
  65. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/430635
推荐阅读
相关标签
  

闽ICP备14008679号