支付寶小程序實現自定義底部彈窗popup組件 - 新聞資訊 - 雲南小程序開發|雲南軟件開發|雲南網站建設-昆明融晨信息技術有限公司

159-8711-8523

雲南網建設/小程序開發/軟件開發

知識

不(bù)管是(shì)網站,軟件還是(shì)小程序,都要(yào / yāo)直接或間接能爲(wéi / wèi)您産生價值,我們在(zài)追求其視覺表現的(de)同時(shí),更側重于(yú)功能的(de)便捷,營銷的(de)便利,運營的(de)高效,讓網站成爲(wéi / wèi)營銷工具,讓軟件能切實提升企業内部管理水平和(hé / huò)效率。優秀的(de)程序爲(wéi / wèi)後期升級提供便捷的(de)支持!

您當前位置>首頁 » 新聞資訊 » 小程序相關 >

支付寶小程序實現自定義底部彈窗popup組件

發表時(shí)間:2020-9-21

發布人(rén):融晨科技

浏覽次數:123

支付寶小程序實現自定義底部彈窗popup組件

view

<view class="am-popup {{className}} {{show ? 'am-popup-show' : ''}} {{ animation ? 'animation': '' }}" disable-scroll="{{disableScroll}}">
  <view class="am-popup-mask" a:if="{{mask}}" onTap="onMaskTap" style="z-index: {{zIndex}}"></view>
  <view class="am-popup-content am-popup-{{position}}" style="z-index: {{zIndex}}"><slot /></view>
</view>

js

Component({
  mixins: [],
  data: {
    
  },
  props: {
    className: '',
    show: false,
    position: 'bottom',
    mask: true,
    animation: true,
    disableScroll: true,
  },
  didMount() {},
  didUpdate() {},
  didUnmount() {},
  methods: {
    onMaskTap() {
      const { onClose, animation } = this.props;

      if (onClose) {
        if (animation) {
          onClose();
        } else {
          setTimeout(() => {
            onClose();
          }, 200);
        }
      }
    },
  },
});

css

.am-popup-content {
  position: fixed;
  z-index: 9999
}

.am-popup-mask {
  visibility: hidden;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.75);
  opacity: 0;
   z-index: 9999;
}

.am-popup-left {
  transform: translateX(-100%);
  left: 0;
  top: 0;
  bottom: 0;
}

.am-popup-right {
  transform: translateX(100%);
  right: 0;
  top: 0;
  bottom: 0;
}

.am-popup-top {
  top: 0;
  width: 100vw;
  transform: translateY(-100%);
}

.am-popup-bottom {
  bottom: 0;
  width: 100vw;
  transform: translateY(100%);
}

.am-popup-show .am-popup-content {
  transform: none;
  background: white;
}

.am-popup-show .am-popup-mask {
  visibility: visible;
  opacity: 1;
}

.am-popup.animation .am-popup-content {
  transition: all 200ms linear;
}

.am-popup.animation .am-popup-mask {
  transition: all 200ms linear;
}

相關案例查看更多