0.0.17 • Published 4 years ago

@retailwe/ui-sidebar v0.0.17

Weekly downloads
1
License
-
Repository
-
Last release
4 years ago

Sidebar 侧边导航

引入

全局引入,在 miniprogram 根目录下的app.json中配置,局部引入,在需要引入的页面或组件的index.json中配置。

// app.json 或 index.json
"usingComponents": {
   "sidebar": "@retailwe/ui-sidebar/index",
    "sidebar-item": "@retailwe/ui-sidebar/sidebar-item/index"
}

代码演示

基础用法

通过在sidebar上设置activeKey属性来控制选中项

<sidebar active-key="{{ activeKey }}" bind:change="onChange">
  <sidebar-item title="标签名称" />
  <sidebar-item title="标签名称" />
  <sidebar-item title="标签名称" />
</sidebar>
Page({
  data: {
    activeKey: 0,
  },

  onChange(event) {
    wx.showToast({
      icon: 'none',
      title: `切换至第${event.detail.index}项`,
    });
  },
});

提示气泡

设置dot属性后,会在右上角展示一个小红点。设置info属性后,会在右上角展示相应的徽标

<wr-sidebar active-key="{{ activeKey }}">
  <wr-sidebar-item title="标签名称" dot />
  <wr-sidebar-item title="标签名称" info="5" />
  <wr-sidebar-item title="标签名称" info="99+" />
</wr-sidebar>

API

Sidebar Props

参数说明类型默认值版本
activeKey选中项的索引string | number0-

Sidebar Event

事件名说明参数
change切换选项时触发当前选中选项的索引

Sidebar 外部样式类

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

SidebarItem Props

参数说明类型默认值版本
title内容string''-
disabled是否禁用booleanfalse-
dot是否显示右上角小红点booleanfalse-
info提示消息string | number''-

SidebarItem Event

事件名说明参数
click点击徽章时触发当前徽章的索引

SidebarItem 外部样式类

类名说明
wr-class根节点样式类
0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7-beta.1

4 years ago