Popup 弹出层

使用指南

在 page.json 中引入组件

  1. "usingComponents": {
  2. "w-popup": "wuss-weapp/w-popup/index",
  3. }

视频演示

代码演示

  1. <w-pane title="Popup" desc="弹出层" />
  2. <w-pane desc="Position" />
  3. <w-button type="info" bind:onClick="handleClick1">Top</w-button>
  4. <w-popup
  5. visible="{{ popup1 }}"
  6. position="top"
  7. height="250px"
  8. bind:onClose="handleClose"
  9. >
  10. <scroll-view scroll-y class="scroll-view-x">
  11. <view
  12. class=""
  13. wx:for="{{50}}"
  14. wx:key="index"
  15. hover-class="none"
  16. hover-stop-propagation="false"
  17. >
  18. {{ index }}
  19. </view>
  20. </scroll-view>
  21. </w-popup>
  22. <w-button type="info" bind:onClick="handleClick2">Bottom</w-button>
  23. <w-popup
  24. visible="{{ popup2 }}"
  25. position="bottom"
  26. height="250px"
  27. bind:onClose="handleClose"
  28. >
  29. <scroll-view scroll-y class="scroll-view-x">
  30. <view
  31. class=""
  32. wx:for="{{50}}"
  33. wx:key="index"
  34. hover-class="none"
  35. hover-stop-propagation="false"
  36. >
  37. {{ index }}
  38. </view>
  39. </scroll-view>
  40. </w-popup>
  41. <w-button type="info" bind:onClick="handleClick3">Left</w-button>
  42. <w-popup
  43. visible="{{ popup3 }}"
  44. position="left"
  45. bind:onClose="handleClose"
  46. >
  47. <scroll-view scroll-y class="scroll-view-y">
  48. <view
  49. class=""
  50. wx:for="{{50}}"
  51. wx:key="index"
  52. hover-class="none"
  53. hover-stop-propagation="false"
  54. >
  55. {{ index }}
  56. </view>
  57. </scroll-view>
  58. </w-popup>
  59. <w-button type="info" bind:onClick="handleClick4">Right</w-button>
  60. <w-popup
  61. visible="{{ popup6 }}"
  62. position="main"
  63. height="45%"
  64. width="72%"
  65. padding="0"
  66. bind:onClose="handleClose"
  67. wuss-class="wuss-popup"
  68. >
  69. <view class="demo-popup-6">
  70. <w-qr-code size="200" text="hello world" />
  71. <w-icon bindtap="handleClose" type="close" color="#999999" wuss-class="w-icon" />
  72. </view>
  73. </w-popup>
  74. <w-button type="info" bind:onClick="handleClick6">Main</w-button>
  75. <w-popup
  76. visible="{{ popup4 }}"
  77. position="right"
  78. bind:onClose="handleClose"
  79. >
  80. <scroll-view scroll-y class="scroll-view-y">
  81. <view
  82. class=""
  83. wx:for="{{50}}"
  84. wx:key="index"
  85. hover-class="none"
  86. hover-stop-propagation="false"
  87. >
  88. {{ index }}
  89. </view>
  90. </scroll-view>
  91. </w-popup>
  92. <w-pane desc="Disabled MaskCancel" />
  93. <w-button type="info" bind:onClick="handleClick5">Info</w-button>
  94. <w-popup
  95. maskCancel="{{ false }}"
  96. visible="{{ popup5 }}"
  97. position="bottom"
  98. height="250px"
  99. bind:onClose="handleClose"
  100. >
  101. <scroll-view scroll-y class="scroll-view-x">
  102. <view
  103. class=""
  104. wx:for="{{50}}"
  105. wx:key="index"
  106. hover-class="none"
  107. hover-stop-propagation="false"
  108. >
  109. 下拉点击关闭按钮{{ index }}
  110. </view>
  111. <w-button type="info" bind:onClick="handleClose">关闭</w-button>
  112. </scroll-view>
  113. </w-popup>
  1. data: {
  2. popup1: false,
  3. popup2: false,
  4. popup3: false,
  5. popup4: false,
  6. popup5: false,
  7. popup6: false,
  8. },
  9. handleClose() {
  10. this.setData({
  11. popup1: false,
  12. popup2: false,
  13. popup3: false,
  14. popup4: false,
  15. popup5: false,
  16. popup6: false,
  17. });
  18. },
  19. handleClick1() {
  20. this.setData({ popup1: true });
  21. },
  22. handleClick2() {
  23. this.setData({ popup2: true });
  24. },
  25. handleClick3() {
  26. this.setData({ popup3: true });
  27. },
  28. handleClick4() {
  29. this.setData({ popup4: true });
  30. },
  31. handleClick5() {
  32. this.setData({ popup5: true });
  33. },
  34. handleClick6() {
  35. this.setData({ popup6: true });
  36. },
  1. .scroll-view-x {
  2. height: 250px;
  3. width: 100%;
  4. }
  5. .scroll-view-y {
  6. height: 100%;
  7. }

API

Attribute 属性

属性说明类型默认值
visible组件是否可见booleanfalse
position弹出位置,可选值:[left,right,top,bottom,main]string-
mask是否开启遮罩层booleanfalse
maskIndex当前组件的 z-index 值number-
width内容区的宽度,当 type 的值为 left,right 时生效string-
height内容区的高度,当 type 的值为 top,bottom 时生效string-
padding内容区的内边距string-
stylesstring-
zIndexnumber-
maskCancel点击遮罩层可否关闭booleanfalse

Event 事件

事件名说明参数
onClosepopup关闭时的回调——

Slot 插槽

名称说明

Class 自定义类名

类名说明
wuss-class
wuss-popup-content