index.js 901 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { use } from '../utils';
  2. import { PopupMixin } from '../mixins/popup';
  3. const [sfc, bem] = use('popup');
  4. export default sfc({
  5. mixins: [PopupMixin],
  6. props: {
  7. position: String,
  8. transition: String,
  9. overlay: {
  10. type: Boolean,
  11. default: true
  12. },
  13. closeOnClickOverlay: {
  14. type: Boolean,
  15. default: true
  16. }
  17. },
  18. render(h) {
  19. if (!this.shouldRender) {
  20. return;
  21. }
  22. const { position } = this;
  23. const emit = event => () => this.$emit(event);
  24. const transitionName = this.transition || (position ? `van-popup-slide-${position}` : 'van-fade');
  25. return (
  26. <transition
  27. name={transitionName}
  28. onAfterEnter={emit('opened')}
  29. onAfterLeave={emit('closed')}
  30. >
  31. <div vShow={this.value} class={bem({ [position]: position })}>
  32. {this.slots()}
  33. </div>
  34. </transition>
  35. );
  36. }
  37. });