弹出框 Popup

基本用法

弹出框 Popup - 图1

  1. <template lang="html">
  2. <main>
  3. <div class="demo-hidden">
  4. <za-panel>
  5. <za-panel-header title="基本"></za-panel-header>
  6. <za-panel-body>
  7. <za-cell>
  8. <za-button size='xs' slot='description' @click='visible1 = true'>开启</za-button>
  9. 从上方弹出
  10. </za-cell>
  11. <za-cell>
  12. <za-button size='xs' slot='description' @click='visible2 = true'>开启</za-button>
  13. 从下方弹出
  14. </za-cell>
  15. <za-cell>
  16. <za-button size='xs' slot='description' @click='visible3 = true'>开启</za-button>
  17. 从左侧弹出
  18. </za-cell>
  19. <za-cell>
  20. <za-button size='xs' slot='description' @click='visible4 = true'>开启</za-button>
  21. 从右侧弹出
  22. </za-cell>
  23. </za-panel-body>
  24. </za-panel>
  25. </div>
  26. <za-popup
  27. style="zIndex:2000"
  28. :visible.sync='visible1'
  29. direction="top"
  30. :duration='3000'
  31. maskType="transparent"
  32. autoClose
  33. @close='popupClose'
  34. >
  35. <div class="popup-box-top" style="width: 100%;padding: 10px;background: rgba(0,0,0,.7);color: #fff;font-size: 14px;text-align: center;">更新成功</div>
  36. </za-popup>
  37. <za-popup
  38. :visible.sync='visible2'
  39. direction="bottom"
  40. @close='popupClose'
  41. >
  42. <div class="popup-box" style="height: 100%;padding: 20px 20px 100px;background: #fff;">
  43. <za-button size="sm" @click='visible2 = false'>关闭弹层</za-button>
  44. </div>
  45. </za-popup>
  46. <za-popup
  47. :visible.sync='visible3'
  48. direction="left"
  49. @close='popupClose'
  50. >
  51. <div class="popup-box-left" style="width:160px;height: 100%;padding: 20px 20px 100px;background: #fff;">
  52. <za-button size="sm" @click='visible3 = false'>关闭弹层</za-button>
  53. </div>
  54. </za-popup>
  55. <za-popup
  56. :visible.sync='visible4'
  57. direction="right"
  58. @close='popupClose'
  59. >
  60. <div class="popup-box" style="width:160px;height: 100%;padding: 20px 20px 100px;background: #fff;">
  61. <za-button size="sm" @click='visible4 = false'>关闭弹层</za-button>
  62. </div>
  63. </za-popup>
  64. </main>
  65. </template>
  66. <script>
  67. export default {
  68. data() {
  69. return {
  70. visible1: false,
  71. visible2: false,
  72. visible3: false,
  73. visible4: false,
  74. }
  75. },
  76. methods: {
  77. popupClose(reason, event) {
  78. console.log(reason, event);
  79. },
  80. },
  81. };
  82. </script>

API

Popup Attributes

属性类型默认值可选值/参数说明
prefixClsstringza-popup类名前缀
visibleboolfalse是否显示, 支持.sync修饰符
directionstring'bottom''top', 'bottom', 'left', 'right'弹出方向
autoCloseboolfalse是否自动关闭
durationnumber3000自动关闭前停留的时间(单位:毫秒)
maskTypestring'normal''transparent', 'light', 'normal', 'dark'遮罩层的类型
onClosefuncnoop关闭后触发的回调函数

Popup Events

事件名称说明回调参数
close关闭后触发的事件reason, event 事件对象