SwiperOut 侧滑菜单

使用指南

在 page.json 中引入组件

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

视频演示

代码演示

  1. <w-pane title="SwiperOut" desc="侧滑菜单" />
  2. <w-pane desc="Default" />
  3. <w-swiper-out
  4. swiperOutBtns="{{ btns1 }}"
  5. data-itemid="sdadasdas123"
  6. bind:delete="delete"
  7. bind:edit="edit"
  8. bind:added="added"
  9. >
  10. <view class="example-content" style="" >
  11. Example Content
  12. </view>
  13. </w-swiper-out>
  14. <w-pane desc="Multiple" />
  15. <w-swiper-out
  16. swiperOutBtns="{{ btns2 }}"
  17. bind:delete="delete"
  18. bind:edit="edit"
  19. bind:added="added"
  20. >
  21. <view class="example-content" style="" >
  22. Example Content
  23. </view>
  24. </w-swiper-out>
  25. <w-pane desc="ButtonWidth = 50" />
  26. <w-swiper-out
  27. swiperOutBtns="{{ btns2 }}"
  28. bind:delete="delete"
  29. bind:edit="edit"
  30. bind:added="added"
  31. buttonWidth="50"
  32. >
  33. <view class="example-content" style="" >
  34. Example Content
  35. </view>
  36. </w-swiper-out>
  37. <w-pane desc="Close = True" />
  38. <w-swiper-out
  39. close
  40. swiperOutBtns="{{ btns1 }}"
  41. bind:delete="delete"
  42. bind:edit="edit"
  43. bind:added="added"
  44. >
  45. <view class="example-content" style="" >
  46. Example Content
  47. </view>
  48. </w-swiper-out>
  49. <w-pane desc="Threshold = 0.7" />
  50. <w-swiper-out
  51. swiperOutBtns="{{ btns1 }}"
  52. bind:delete="delete"
  53. bind:edit="edit"
  54. bind:added="added"
  55. threshold=".7"
  56. >
  57. <view class="example-content" style="" >
  58. Example Content
  59. </view>
  60. </w-swiper-out>
  61. <w-pane desc="AutoClose = False" />
  62. <w-swiper-out
  63. autoClose="{{false}}"
  64. swiperOutBtns="{{ btns2 }}"
  65. bind:delete="delete"
  66. bind:edit="edit"
  67. bind:added="added"
  68. >
  69. <view class="example-content" style="" >
  70. Example Content
  71. </view>
  72. </w-swiper-out>
  73. <w-pane desc="Disabled = True" />
  74. <w-swiper-out
  75. disabled
  76. swiperOutBtns="{{ btns2 }}"
  77. bind:delete="delete"
  78. bind:edit="edit"
  79. bind:added="added"
  80. >
  81. <view class="example-content" style="" >
  82. Example Content
  83. </view>
  84. </w-swiper-out>
  85. <w-pane desc="BackgroundColor = f8f8f8" />
  86. <w-swiper-out
  87. backgroundColor="#f8f8f8"
  88. swiperOutBtns="{{ btns2 }}"
  89. bind:delete="delete"
  90. bind:edit="edit"
  91. bind:added="added"
  92. >
  93. <view class="example-content" style="" >
  94. Example Content
  95. </view>
  96. </w-swiper-out>
  1. data: {
  2. btns1: [
  3. {
  4. text: '添加',
  5. color: '#ffffff',
  6. background: '#28a745',
  7. disabled: false,
  8. size: '14px',
  9. type: 'added',
  10. },
  11. {
  12. text: '删除',
  13. color: '#ffffff',
  14. background: '#e42112',
  15. disabled: false,
  16. size: '14px',
  17. type: 'delete',
  18. },
  19. ],
  20. btns2: [
  21. {
  22. text: '添加',
  23. color: '#ffffff',
  24. background: '#28a745',
  25. disabled: false,
  26. size: '14px',
  27. type: 'added',
  28. },
  29. {
  30. text: '编辑',
  31. color: '#ffffff',
  32. background: '#ff8800',
  33. disabled: false,
  34. size: '14px',
  35. type: 'edit',
  36. },
  37. {
  38. text: '删除',
  39. color: '#ffffff',
  40. background: '#e42112',
  41. disabled: false,
  42. size: '14px',
  43. type: 'delete',
  44. },
  45. ],
  46. },
  47. added() {
  48. wx.showModal({
  49. title: '提示',
  50. content: 'added',
  51. showCancel: false,
  52. });
  53. },
  54. delete(e) {
  55. wx.showModal({
  56. title: '提示',
  57. content: 'delete',
  58. showCancel: false,
  59. });
  60. },
  61. edit() {
  62. wx.showModal({
  63. title: '提示',
  64. content: 'edit',
  65. showCancel: false,
  66. });
  67. },
  68. handleBtnClick(e) {
  69. const { onPress } = e.detail;
  70. onPress.call(this);
  71. },
  1. .example-content {
  2. display: flex;
  3. align-items: center;
  4. padding: 0 10px;
  5. }

API

Attribute 属性

属性说明类型默认值
swiperOutBtns侧滑菜单按钮列表参数有 text,color,background,disabledarray[]
backgroundColor背景颜色string-
buttonWidth按钮的宽度number-
height容器的高度number-
threshold侧滑触发的阀值number-
close是否展开booleanfalse
autoClose点击按钮自动收起booleanfalse
disabled禁用侧滑菜单booleanfalse

Event 事件

事件名说明参数

Slot 插槽

名称说明

Class 自定义类名

类名说明
wuss-class根节点样式类