mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
68 lines
1.3 KiB
Markdown
68 lines
1.3 KiB
Markdown
## Sidebar
|
|
|
|
### Install
|
|
|
|
``` javascript
|
|
import { Sidebar, SidebarItem } from 'vant';
|
|
|
|
Vue.use(Sidebar);
|
|
Vue.use(SidebarItem);
|
|
```
|
|
|
|
### Usage
|
|
|
|
#### Basic Usage
|
|
|
|
Use `active-key` prop to set index of chosen item
|
|
|
|
```html
|
|
<van-sidebar :active-key="activeKey" @change="onChange">
|
|
<van-sidebar-item title="Title" />
|
|
<van-sidebar-item title="Title" info="8" />
|
|
<van-sidebar-item title="Title" info="99" />
|
|
<van-sidebar-item title="Title" info="99+" />
|
|
</van-sidebar>
|
|
```
|
|
|
|
``` javascript
|
|
export default {
|
|
data() {
|
|
return {
|
|
activeKey: 0
|
|
};
|
|
},
|
|
|
|
methods: {
|
|
onChange(key) {
|
|
this.activeKey = key;
|
|
}
|
|
}
|
|
};
|
|
```
|
|
|
|
### Sidebar API
|
|
|
|
| Attribute | Description | Type | Default |
|
|
|------|------|------|------|
|
|
| active-key | Index of chosen item | `String | Number` | `0` |
|
|
|
|
### Sidebar Event
|
|
|
|
| Event | Description | Arguments |
|
|
|------|------|------|
|
|
| change | Triggered when item changed | key: index of current item |
|
|
|
|
### SidebarItem API
|
|
|
|
| Attribute | Description | Type | Default |
|
|
|------|------|------|------|
|
|
| title | Content | `String` | `''` |
|
|
| info | Info Message | `String | Number` | `''` |
|
|
| url | Link | `String` | - |
|
|
|
|
### SidebarItem Event
|
|
|
|
| Event | Description | Arguments |
|
|
|------|------|------|
|
|
| click | Triggered when click item | key: index of current item |
|