mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(TreeSelect): add className option (#4671)
This commit is contained in:
parent
514a27994a
commit
cc03640576
@ -145,6 +145,8 @@ In every tree object, `text` property defines `id` stands for the unique key whi
|
|||||||
info: 3,
|
info: 3,
|
||||||
// Whether to show red dot
|
// Whether to show red dot
|
||||||
dot: true,
|
dot: true,
|
||||||
|
// ClassName of parent node
|
||||||
|
className: 'my-class',
|
||||||
// leaves of this parent node
|
// leaves of this parent node
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -151,6 +151,8 @@ export default {
|
|||||||
info: 3,
|
info: 3,
|
||||||
// 是否在导航名称右上角显示小红点
|
// 是否在导航名称右上角显示小红点
|
||||||
dot: true,
|
dot: true,
|
||||||
|
// 导航节点额外类名
|
||||||
|
className: 'my-class',
|
||||||
// 该导航下所有的可选项
|
// 该导航下所有的可选项
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ export type TreeSelectItem = {
|
|||||||
dot?: boolean;
|
dot?: boolean;
|
||||||
info?: string | number;
|
info?: string | number;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
className?: any;
|
||||||
children: TreeSelectChildren[];
|
children: TreeSelectChildren[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ function TreeSelect(
|
|||||||
info={item.info}
|
info={item.info}
|
||||||
title={item.text}
|
title={item.text}
|
||||||
disabled={item.disabled}
|
disabled={item.disabled}
|
||||||
class={bem('nav-item')}
|
class={[bem('nav-item'), item.className]}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -262,7 +262,6 @@ test('max prop', () => {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
activeId: [],
|
activeId: [],
|
||||||
mainActiveIndex: 0,
|
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
text: 'group1',
|
text: 'group1',
|
||||||
@ -278,3 +277,21 @@ test('max prop', () => {
|
|||||||
items.at(1).trigger('click');
|
items.at(1).trigger('click');
|
||||||
expect(wrapper.vm.activeId).toEqual([mockItem.id]);
|
expect(wrapper.vm.activeId).toEqual([mockItem.id]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('className of nav', () => {
|
||||||
|
const wrapper = mount(TreeSelect, {
|
||||||
|
propsData: {
|
||||||
|
mainActiveIndex: 0,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: 'group1',
|
||||||
|
className: 'my-class',
|
||||||
|
children: []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const items = wrapper.findAll('.van-tree-select__nav-item');
|
||||||
|
expect(items.at(0).element.classList.contains('my-class')).toBeTruthy();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user