Drawer 抽屉

使用指南

在 .json 中引入组件

  1. "usingComponents": {
  2. "i-drawer": "../../dist/drawer/index"
  3. }

示例

  1. <i-button bind:click="toggleLeft1" type="ghost">左边弹出1</i-button>
  2. <i-button bind:click="toggleLeft2" type="primary">左边弹出2</i-button>
  3. <i-button bind:click="toggleRight1" type="ghost">右边弹出1</i-button>
  4. <i-button bind:click="toggleRight2" type="primary">右边弹出2</i-button>
  5. <i-drawer mode="left" visible="{{showLeft1}}" bind:close="toggleLeft1">
  6. <view class="demo-container">
  7. 单击遮罩层关闭
  8. </view>
  9. </i-drawer>
  10. <i-drawer mode="left" visible="{{showLeft2}}" mask-closable="{{false}}">
  11. <view class="demo-container">
  12. 禁止单击遮罩关闭
  13. <i-button bind:click="toggleLeft2" type="primary">关闭</i-button>
  14. </view>
  15. </i-drawer>
  16. <i-drawer mode="right" visible="{{showRight1}}" bind:close="toggleRight1">
  17. <view class="demo-container">
  18. 单击遮罩层关闭
  19. </view>
  20. </i-drawer>
  21. <i-drawer mode="right" visible="{{showRight2}}" mask-closable="{{false}}">
  22. <view class="demo-container">
  23. 禁止单击遮罩关闭
  24. <i-button bind:click="toggleRight2" type="primary">关闭</i-button>
  25. </view>
  26. </i-drawer>
  1. Page({
  2. data: {
  3. showLeft1: false,
  4. showLeft2: false,
  5. showRight1: false,
  6. showRigh2: false,
  7. },
  8. toggleLeft1() {
  9. this.setData({
  10. showLeft1: !this.data.showLeft1
  11. });
  12. },
  13. toggleLeft2() {
  14. this.setData({
  15. showLeft2: !this.data.showLeft2
  16. });
  17. },
  18. toggleRight1() {
  19. this.setData({
  20. showRight1: !this.data.showRight1
  21. });
  22. },
  23. toggleRight2() {
  24. this.setData({
  25. showRight2: !this.data.showRight2
  26. });
  27. }
  28. });

API

Drawer properties

属性说明类型默认值
i-class自定义 class 类名String-
visible是否显示组件String-
mode显示位置,可选值为 left 和 rightStringleft
mask是否显示遮罩层Booleantrue
mask-closable是否允许点击遮罩层关闭Booleantrue

Drawer events

事件名说明返回值
bind:close关闭时触发-