Skip to content

Drawer 抽屉


抽屉菜单

使用指南

在 Taro 文件中引入组件

js
import { AtDrawer } from 'taro-ui'

组件依赖的样式文件(仅按需引用时需要)

scss
@import "~taro-ui/dist/style/components/drawer.scss";
@import "~taro-ui/dist/style/components/list.scss";

用法

html
<AtDrawer 
  show={this.state.show} 
  mask 
  onClose={this.onClose.bind(this)} 
  items={['菜单1', '菜单2']}
></AtDrawer>

右边弹出

html
<AtDrawer 
  show={this.state.show} 
  right 
  mask 
  onClose={this.onClose.bind(this)} 
  items={['菜单1', '菜单2']}
></AtDrawer>

自定义内容

html
<AtDrawer
  show={this.state.show}
  mask
>
  <View className='drawer-item'>优先展示items里的数据</View>
  <View className='drawer-item'>如果items没有数据就会展示children</View>
  <View className='drawer-item'>这是自定义内容 <AtIcon value='home' size='20' /></View>
  <View className='drawer-item'>这是自定义内容</View>
</AtDrawer>

Drawer 参数

参数说明类型可选值默认值
show展示或隐藏Boolean-false
mask是否需要遮罩Boolean-true
width抽屉宽度String合法的 CSS 宽度单位230px
right是否从右侧滑出Boolean-false
items菜单列表Array--

Drawer 事件

事件名称说明返回参数
onItemClick点击菜单时触发index(菜单序号)
onClose动画结束组件关闭的时候触发-

Released under the MIT License.