Badge add count slot
This commit is contained in:
parent
91806ae7f5
commit
ed0817359c
3 changed files with 25 additions and 4 deletions
|
@ -20,10 +20,14 @@
|
||||||
<Badge :count="0" showZero>
|
<Badge :count="0" showZero>
|
||||||
<a href="#" class="demo-badge"></a>
|
<a href="#" class="demo-badge"></a>
|
||||||
</Badge>
|
</Badge>
|
||||||
|
<Badge>
|
||||||
|
<Icon type="md-time" slot="count" size="16" color="#ff6600" />
|
||||||
|
<a href="#" class="demo-badge"></a>
|
||||||
|
</Badge>
|
||||||
<Button @click="setCount">set count</Button>
|
<Button @click="setCount">set count</Button>
|
||||||
<br><br>
|
<br><br>
|
||||||
<Badge text="hot">
|
<Badge text="hot">
|
||||||
<Button type="ghost">Hello</Button>
|
<Button type="primary" ghost>Hello</Button>
|
||||||
</Badge>
|
</Badge>
|
||||||
<br><br>
|
<br><br>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
</span>
|
</span>
|
||||||
<span v-else :class="classes" ref="badge">
|
<span v-else :class="classes" ref="badge">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<sup v-if="hasCount" :style="styles" :class="countClasses" v-show="badge">{{ finalCount }}</sup>
|
<sup v-if="$slots.count" :style="styles" :class="customCountClasses"><slot name="count"></slot></sup>
|
||||||
|
<sup v-else-if="hasCount" :style="styles" :class="countClasses" v-show="badge">{{ finalCount }}</sup>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
@ -68,6 +69,15 @@
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
customCountClasses () {
|
||||||
|
return [
|
||||||
|
`${prefixCls}-count`,
|
||||||
|
`${prefixCls}-count-custom`,
|
||||||
|
{
|
||||||
|
[`${this.className}`]: !!this.className,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
},
|
||||||
statusClasses () {
|
statusClasses () {
|
||||||
return [
|
return [
|
||||||
`${prefixCls}-status-dot`,
|
`${prefixCls}-status-dot`,
|
||||||
|
|
|
@ -27,6 +27,13 @@
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
box-shadow: 0 0 0 1px #fff;
|
box-shadow: 0 0 0 1px #fff;
|
||||||
|
|
||||||
|
&-custom{
|
||||||
|
background: transparent;
|
||||||
|
color: inherit;
|
||||||
|
border-color: transparent;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
a,
|
a,
|
||||||
a:hover {
|
a:hover {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|
Loading…
Add table
Reference in a new issue