mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(SidebarItem): add title slot (#7220)
This commit is contained in:
parent
f609c224b1
commit
e201bc55ee
@ -43,7 +43,7 @@ export default createComponent({
|
|||||||
onClick={this.onClick}
|
onClick={this.onClick}
|
||||||
>
|
>
|
||||||
<div class={bem('text')}>
|
<div class={bem('text')}>
|
||||||
{this.title}
|
{this.slots('title') ?? this.title}
|
||||||
<Info
|
<Info
|
||||||
dot={this.dot}
|
dot={this.dot}
|
||||||
info={this.badge ?? this.info}
|
info={this.badge ?? this.info}
|
||||||
|
@ -110,3 +110,9 @@ export default {
|
|||||||
| Event | Description | Arguments |
|
| Event | Description | Arguments |
|
||||||
| ----- | ------------------------- | ---------------------------- |
|
| ----- | ------------------------- | ---------------------------- |
|
||||||
| click | Triggered when click item | index: index of current item |
|
| click | Triggered when click item | index: index of current item |
|
||||||
|
|
||||||
|
### SidebarItem Slots
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| ----- | ---------------- |
|
||||||
|
| title | Custom item title |
|
||||||
|
@ -119,3 +119,9 @@ export default {
|
|||||||
| 事件名 | 说明 | 回调参数 |
|
| 事件名 | 说明 | 回调参数 |
|
||||||
| ------ | ---------- | ----------------------- |
|
| ------ | ---------- | ----------------------- |
|
||||||
| click | 点击时触发 | index: 当前导航项的索引 |
|
| click | 点击时触发 | index: 当前导航项的索引 |
|
||||||
|
|
||||||
|
### SidebarItem Slots
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| ----- | ----------- |
|
||||||
|
| title | 自定义标题 |
|
||||||
|
9
src/sidebar/test/__snapshots__/index.spec.js.snap
Normal file
9
src/sidebar/test/__snapshots__/index.spec.js.snap
Normal file
@ -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>
|
||||||
|
`;
|
@ -76,3 +76,22 @@ test('without parent', () => {
|
|||||||
expect(err).toBeTruthy();
|
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();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user