Merge branch 'dev' into next

This commit is contained in:
chenjiahan
2020-09-22 19:42:24 +08:00
20 changed files with 245 additions and 29 deletions
+6
View File
@@ -111,3 +111,9 @@ export default {
| Event | Description | Arguments |
| ----- | ------------------------- | ---------------------------- |
| click | Triggered when click item | index: index of current item |
### SidebarItem Slots
| Name | Description |
| --------------- | ----------------- |
| title `v2.10.8` | Custom item title |
+10 -4
View File
@@ -15,7 +15,7 @@ app.use(SidebarItem);
### 基础用法
通过`v-model`绑定当前选中项的索引
通过 `v-model` 绑定当前选中项的索引
```html
<van-sidebar v-model="activeKey">
@@ -37,7 +37,7 @@ export default {
### 徽标提示
设置`dot`属性后,会在右上角展示一个小红点设置`badge`属性后,会在右上角展示相应的徽标
设置 `dot` 属性后,会在右上角展示一个小红点设置 `badge` 属性后,会在右上角展示相应的徽标
```html
<van-sidebar v-model="activeKey">
@@ -49,7 +49,7 @@ export default {
### 禁用选项
通过`disabled`属性禁用选项
通过 `disabled` 属性禁用选项
```html
<van-sidebar v-model="activeKey">
@@ -61,7 +61,7 @@ export default {
### 监听切换事件
设置`change`方法来监听切换导航项时的事件
设置 `change` 方法来监听切换导航项时的事件
```html
<van-sidebar v-model="activeKey" @change="onChange">
@@ -119,3 +119,9 @@ export default {
| 事件名 | 说明 | 回调参数 |
| ------ | ---------- | ----------------------- |
| click | 点击时触发 | index: 当前导航项的索引 |
### SidebarItem Slots
| Name | Description |
| --------------- | ----------- |
| title `v2.10.8` | 自定义标题 |
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`title slot 1`] = `
<div class="van-sidebar"><a class="van-sidebar-item van-sidebar-item--select">
<div class="van-sidebar-item__text">Title Slot
<!---->
</div>
</a></div>
`;
+19
View File
@@ -76,3 +76,22 @@ test('without parent', () => {
expect(err).toBeTruthy();
}
});
test('title slot', () => {
const wrapper = mount({
template: `
<van-sidebar v-model="active">
<van-sidebar-item>
<template #title>Title Slot</template>
</van-sidebar-item>
</van-sidebar>
`,
data() {
return {
active: 0,
};
},
});
expect(wrapper).toMatchSnapshot();
});