mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 02:16:12 +08:00
feat(TreeSelect): support show info (#4384)
This commit is contained in:
parent
5b0feb58e8
commit
4529bd6b30
@ -123,6 +123,8 @@ In every tree object, `text` property defines `id` stands for the unique key whi
|
|||||||
{
|
{
|
||||||
// name of the parent node
|
// name of the parent node
|
||||||
text: 'Group 1',
|
text: 'Group 1',
|
||||||
|
// info
|
||||||
|
info: 3,
|
||||||
// leaves of this parent node
|
// leaves of this parent node
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -129,6 +129,8 @@ export default {
|
|||||||
{
|
{
|
||||||
// 导航名称
|
// 导航名称
|
||||||
text: '所有城市',
|
text: '所有城市',
|
||||||
|
// 导航名称右上角徽标
|
||||||
|
info: 3,
|
||||||
// 该导航下所有的可选项
|
// 该导航下所有的可选项
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,7 @@ import { DefaultSlots, ScopedSlot } from '../utils/types';
|
|||||||
|
|
||||||
export type TreeSelectItem = {
|
export type TreeSelectItem = {
|
||||||
text: string;
|
text: string;
|
||||||
|
info?: string | number;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
children: TreeSelectChildren[];
|
children: TreeSelectChildren[];
|
||||||
};
|
};
|
||||||
@ -54,8 +55,9 @@ function TreeSelect(
|
|||||||
: activeId === id;
|
: activeId === id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Nav = items.map(item => (
|
const Navs = items.map(item => (
|
||||||
<SidebarItem
|
<SidebarItem
|
||||||
|
info={item.info}
|
||||||
title={item.text}
|
title={item.text}
|
||||||
disabled={item.disabled}
|
disabled={item.disabled}
|
||||||
class={bem('nav-item')}
|
class={bem('nav-item')}
|
||||||
@ -121,7 +123,7 @@ function TreeSelect(
|
|||||||
emit(ctx, 'navclick', index);
|
emit(ctx, 'navclick', index);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Nav}
|
{Navs}
|
||||||
</Sidebar>
|
</Sidebar>
|
||||||
<div class={bem('content')}>{Content()}</div>
|
<div class={bem('content')}>{Content()}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -24,3 +24,13 @@ exports[`height prop 1`] = `
|
|||||||
<div class="van-tree-select__content"></div>
|
<div class="van-tree-select__content"></div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`nav info 1`] = `
|
||||||
|
<div class="van-tree-select" style="height: 300px;">
|
||||||
|
<div class="van-sidebar van-tree-select__nav"><a class="van-sidebar-item van-sidebar-item--select van-tree-select__nav-item">
|
||||||
|
<div class="van-sidebar-item__text">group1<div class="van-info van-sidebar-item__info">3</div>
|
||||||
|
</div>
|
||||||
|
</a></div>
|
||||||
|
<div class="van-tree-select__content"></div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
@ -150,6 +150,21 @@ test('height prop', () => {
|
|||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('nav info', () => {
|
||||||
|
const wrapper = mount(TreeSelect, {
|
||||||
|
propsData: {
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: 'group1',
|
||||||
|
info: 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
test('use sync modifier in main-active-index', () => {
|
test('use sync modifier in main-active-index', () => {
|
||||||
const wrapper = mount({
|
const wrapper = mount({
|
||||||
template: `
|
template: `
|
||||||
|
Loading…
x
Reference in New Issue
Block a user