mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 19:41:42 +08:00
feat(SidebarItem): add badge prop, mark info prop as deprecated
This commit is contained in:
parent
d61cbdd086
commit
01482f20bc
@ -1,4 +1,4 @@
|
||||
import { createNamespace } from '../utils';
|
||||
import { createNamespace, isDef } from '../utils';
|
||||
import { ChildrenMixin } from '../mixins/relation';
|
||||
import { route, routeProps } from '../utils/router';
|
||||
import Info from '../info';
|
||||
@ -12,6 +12,7 @@ export default createComponent({
|
||||
...routeProps,
|
||||
dot: Boolean,
|
||||
info: [Number, String],
|
||||
badge: [Number, String],
|
||||
title: String,
|
||||
disabled: Boolean,
|
||||
},
|
||||
@ -43,7 +44,11 @@ export default createComponent({
|
||||
>
|
||||
<div class={bem('text')}>
|
||||
{this.title}
|
||||
<Info dot={this.dot} info={this.info} class={bem('info')} />
|
||||
<Info
|
||||
dot={this.dot}
|
||||
info={isDef(this.badge) ? this.badge : this.info}
|
||||
class={bem('info')}
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
);
|
||||
|
@ -32,13 +32,13 @@ export default {
|
||||
};
|
||||
```
|
||||
|
||||
### Show Info
|
||||
### Show Badge
|
||||
|
||||
```html
|
||||
<van-sidebar v-model="activeKey">
|
||||
<van-sidebar-item title="Title" dot />
|
||||
<van-sidebar-item title="Title" info="5" />
|
||||
<van-sidebar-item title="Title" info="99+" />
|
||||
<van-sidebar-item title="Title" badge="5" />
|
||||
<van-sidebar-item title="Title" badge="99+" />
|
||||
</van-sidebar>
|
||||
```
|
||||
|
||||
@ -99,7 +99,7 @@ export default {
|
||||
|------|------|------|------|
|
||||
| title | Content | *string* | `''` |
|
||||
| dot `v2.2.1` | Whether to show red dot | *boolean* | `false` |
|
||||
| info | Content of the badge | *number \| string* | `''` |
|
||||
| badge `v2.5.6` | Content of the badge | *number \| string* | `''` |
|
||||
| disabled `v2.2.0` | Whether to be disabled | *boolean* | `false` |
|
||||
| url | Link | *string* | - |
|
||||
| to `v2.0.4` | Target route of the link, same as to of vue-router | *string \| object* | - |
|
||||
|
@ -34,15 +34,15 @@ export default {
|
||||
};
|
||||
```
|
||||
|
||||
### 提示信息
|
||||
### 徽标提示
|
||||
|
||||
设置`dot`属性后,会在右上角展示一个小红点。设置`info`属性后,会在右上角展示相应的徽标
|
||||
设置`dot`属性后,会在右上角展示一个小红点。设置`badge`属性后,会在右上角展示相应的徽标
|
||||
|
||||
```html
|
||||
<van-sidebar v-model="activeKey">
|
||||
<van-sidebar-item title="标签名称" dot />
|
||||
<van-sidebar-item title="标签名称" info="5" />
|
||||
<van-sidebar-item title="标签名称" info="99+" />
|
||||
<van-sidebar-item title="标签名称" badge="5" />
|
||||
<van-sidebar-item title="标签名称" badge="99+" />
|
||||
</van-sidebar>
|
||||
```
|
||||
|
||||
@ -108,7 +108,8 @@ export default {
|
||||
|------|------|------|------|
|
||||
| title | 内容 | *string* | `''` |
|
||||
| dot `v2.2.1` | 是否显示右上角小红点 | *boolean* | `false` |
|
||||
| info | 右上角徽标的内容 | *number \| string* | - |
|
||||
| badge `v2.5.6` | 图标右上角徽标的内容 | *number \| string* | - |
|
||||
| info | 图标右上角徽标的内容(已废弃,请使用 badge 属性) | *number \| string* | - |
|
||||
| disabled `v2.2.0` | 是否禁用该项 | *boolean* | `false` |
|
||||
| url | 点击后跳转的链接地址 | *string* | - |
|
||||
| to `v2.0.4` | 点击后跳转的目标路由对象,同 vue-router 的 [to 属性](https://router.vuejs.org/zh/api/#to) | *string \| object* | - |
|
||||
|
@ -11,11 +11,11 @@
|
||||
</van-grid-item>
|
||||
|
||||
<van-grid-item>
|
||||
<h3 class="demo-sidebar-title">{{ $t('showInfo') }}</h3>
|
||||
<h3 class="demo-sidebar-title">{{ $t('showBadge') }}</h3>
|
||||
<van-sidebar v-model="activeKey2">
|
||||
<van-sidebar-item :title="$t('title')" dot />
|
||||
<van-sidebar-item :title="$t('title')" info="5" />
|
||||
<van-sidebar-item :title="$t('title')" info="99+" />
|
||||
<van-sidebar-item :title="$t('title')" badge="5" />
|
||||
<van-sidebar-item :title="$t('title')" badge="99+" />
|
||||
</van-sidebar>
|
||||
</van-grid-item>
|
||||
|
||||
@ -45,13 +45,13 @@ export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
title: '标签名',
|
||||
showInfo: '提示信息',
|
||||
showBadge: '徽标提示',
|
||||
disabled: '禁用选项',
|
||||
changeEvent: '监听切换事件',
|
||||
selectTip: '你切换到了',
|
||||
},
|
||||
'en-US': {
|
||||
showInfo: 'Show Info',
|
||||
showBadge: 'Show Badge',
|
||||
disabled: 'Disabled',
|
||||
changeEvent: 'Change Event',
|
||||
selectTip: 'You select ',
|
||||
|
Loading…
x
Reference in New Issue
Block a user