mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(TreeSelect): add badge option, mark info option as deprecated
This commit is contained in:
parent
214b13b8ff
commit
0cc7a30528
@ -23,7 +23,7 @@ exports[`renders demo correctly 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
<div class="van-grid-item" style="flex-basis: 50%;">
|
<div class="van-grid-item" style="flex-basis: 50%;">
|
||||||
<div class="van-grid-item__content van-grid-item__content--center">
|
<div class="van-grid-item__content van-grid-item__content--center">
|
||||||
<h3 class="demo-sidebar-title">提示信息</h3>
|
<h3 class="demo-sidebar-title">徽标提示</h3>
|
||||||
<div class="van-sidebar"><a class="van-sidebar-item van-sidebar-item--select">
|
<div class="van-sidebar"><a class="van-sidebar-item van-sidebar-item--select">
|
||||||
<div class="van-sidebar-item__text">标签名<div class="van-info van-info--dot van-sidebar-item__info"></div>
|
<div class="van-sidebar-item__text">标签名<div class="van-info van-info--dot van-sidebar-item__info"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -81,7 +81,7 @@ export default {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Show Info
|
### Show Badge
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<van-tree-select
|
<van-tree-select
|
||||||
@ -98,7 +98,7 @@ export default {
|
|||||||
activeIndex: 0,
|
activeIndex: 0,
|
||||||
items: [
|
items: [
|
||||||
{ text: 'Group 1', children: [], dot: true },
|
{ text: 'Group 1', children: [], dot: true },
|
||||||
{ text: 'Group 2', children: [], info: 5 }
|
{ text: 'Group 2', children: [], badge: 5 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,8 +141,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
|
// badge
|
||||||
info: 3,
|
badge: 3,
|
||||||
// Whether to show red dot
|
// Whether to show red dot
|
||||||
dot: true,
|
dot: true,
|
||||||
// ClassName of parent node
|
// ClassName of parent node
|
||||||
|
@ -87,9 +87,9 @@ export default {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 提示信息
|
### 徽标提示
|
||||||
|
|
||||||
设置`dot`属性后,会在图标右上角展示一个小红点。设置`info`属性后,会在图标右上角展示相应的徽标
|
设置`dot`属性后,会在图标右上角展示一个小红点。设置`badge`属性后,会在图标右上角展示相应的徽标
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<van-tree-select
|
<van-tree-select
|
||||||
@ -106,7 +106,7 @@ export default {
|
|||||||
activeIndex: 0,
|
activeIndex: 0,
|
||||||
items: [
|
items: [
|
||||||
{ text: '浙江', children: [], dot: true },
|
{ text: '浙江', children: [], dot: true },
|
||||||
{ text: '江苏', children: [], info: 5 }
|
{ text: '江苏', children: [], badge: 5 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,8 +147,8 @@ export default {
|
|||||||
{
|
{
|
||||||
// 导航名称
|
// 导航名称
|
||||||
text: '所有城市',
|
text: '所有城市',
|
||||||
// 导航名称右上角徽标
|
// 导航名称右上角徽标,2.5.6 版本开始支持
|
||||||
info: 3,
|
badge: 3,
|
||||||
// 是否在导航名称右上角显示小红点
|
// 是否在导航名称右上角显示小红点
|
||||||
dot: true,
|
dot: true,
|
||||||
// 导航节点额外类名
|
// 导航节点额外类名
|
||||||
|
@ -35,10 +35,10 @@
|
|||||||
</van-tree-select>
|
</van-tree-select>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block :title="$t('showInfo')">
|
<demo-block :title="$t('showBadge')">
|
||||||
<van-tree-select
|
<van-tree-select
|
||||||
height="55vw"
|
height="55vw"
|
||||||
:items="infoItems"
|
:items="badgeItems"
|
||||||
:active-id.sync="activeId2"
|
:active-id.sync="activeId2"
|
||||||
:main-active-index.sync="activeIndex4"
|
:main-active-index.sync="activeIndex4"
|
||||||
/>
|
/>
|
||||||
@ -54,7 +54,7 @@ import { deepClone } from '../../utils/deep-clone';
|
|||||||
export default {
|
export default {
|
||||||
i18n: {
|
i18n: {
|
||||||
'zh-CN': {
|
'zh-CN': {
|
||||||
showInfo: '提示信息',
|
showBadge: '提示信息',
|
||||||
radioMode: '单选模式',
|
radioMode: '单选模式',
|
||||||
multipleMode: '多选模式',
|
multipleMode: '多选模式',
|
||||||
customContent: '自定义内容',
|
customContent: '自定义内容',
|
||||||
@ -62,7 +62,7 @@ export default {
|
|||||||
dataSimple: [{ text: '分组 1' }, { text: '分组 2' }],
|
dataSimple: [{ text: '分组 1' }, { text: '分组 2' }],
|
||||||
},
|
},
|
||||||
'en-US': {
|
'en-US': {
|
||||||
showInfo: 'Show Info',
|
showBadge: 'Show Badge',
|
||||||
radioMode: 'Radio Mode',
|
radioMode: 'Radio Mode',
|
||||||
multipleMode: 'Multiple Mode',
|
multipleMode: 'Multiple Mode',
|
||||||
customContent: 'Custom Content',
|
customContent: 'Custom Content',
|
||||||
@ -92,11 +92,11 @@ export default {
|
|||||||
return this.$t('dataSimple');
|
return this.$t('dataSimple');
|
||||||
},
|
},
|
||||||
|
|
||||||
infoItems() {
|
badgeItems() {
|
||||||
const data = deepClone(this.$t('data')).slice(0, 2);
|
const data = deepClone(this.$t('data')).slice(0, 2);
|
||||||
|
|
||||||
data[0].dot = true;
|
data[0].dot = true;
|
||||||
data[1].info = 5;
|
data[1].badge = 5;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Utils
|
// Utils
|
||||||
import { createNamespace, addUnit } from '../utils';
|
import { createNamespace, addUnit, isDef } from '../utils';
|
||||||
import { emit, inherit } from '../utils/functional';
|
import { emit, inherit } from '../utils/functional';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
@ -15,6 +15,7 @@ export type TreeSelectItem = {
|
|||||||
text: string;
|
text: string;
|
||||||
dot?: boolean;
|
dot?: boolean;
|
||||||
info?: string | number;
|
info?: string | number;
|
||||||
|
badge?: string | number;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
className?: any;
|
className?: any;
|
||||||
children: TreeSelectChildren[];
|
children: TreeSelectChildren[];
|
||||||
@ -63,7 +64,7 @@ function TreeSelect(
|
|||||||
const Navs = items.map(item => (
|
const Navs = items.map(item => (
|
||||||
<SidebarItem
|
<SidebarItem
|
||||||
dot={item.dot}
|
dot={item.dot}
|
||||||
info={item.info}
|
info={isDef(item.badge) ? item.badge : item.info}
|
||||||
title={item.text}
|
title={item.text}
|
||||||
disabled={item.disabled}
|
disabled={item.disabled}
|
||||||
class={[bem('nav-item'), item.className]}
|
class={[bem('nav-item'), item.className]}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user