Commit 457fe0874c1a84db7e9478c326d88b32c94b24ec
1 parent
7b959eba
update Badge style
Showing
2 changed files
with
19 additions
and
2 deletions
Show diff stats
examples/routers/badge.vue
... | ... | @@ -43,6 +43,15 @@ |
43 | 43 | <br /> |
44 | 44 | <Badge status="warning" text="Warning" /> |
45 | 45 | </div> |
46 | + <div style="margin: 50px"> | |
47 | + <Badge dot> | |
48 | + <a href="//iviewui.com">我是一个链接</a> | |
49 | + </Badge> | |
50 | + <br><br> | |
51 | + <Badge :count="10" :offset="[-5, -5]"> | |
52 | + <a href="//iviewui.com">我是一个链接</a> | |
53 | + </Badge> | |
54 | + </div> | |
46 | 55 | </div> |
47 | 56 | </template> |
48 | 57 | <script> | ... | ... |
src/components/badge/badge.vue
1 | 1 | <template> |
2 | 2 | <span v-if="dot" :class="classes" ref="badge"> |
3 | 3 | <slot></slot> |
4 | - <sup :class="dotClasses" v-show="badge"></sup> | |
4 | + <sup :class="dotClasses" :style="styles" v-show="badge"></sup> | |
5 | 5 | </span> |
6 | 6 | <span v-else-if="status" :class="classes" class="ivu-badge-status" ref="badge"> |
7 | 7 | <span :class="statusClasses"></span> |
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | </span> |
10 | 10 | <span v-else :class="classes" ref="badge"> |
11 | 11 | <slot></slot> |
12 | - <sup v-if="hasCount" :class="countClasses" v-show="badge">{{ finalCount }}</sup> | |
12 | + <sup v-if="hasCount" :style="styles" :class="countClasses" v-show="badge">{{ finalCount }}</sup> | |
13 | 13 | </span> |
14 | 14 | </template> |
15 | 15 | <script> |
... | ... | @@ -70,6 +70,14 @@ |
70 | 70 | } |
71 | 71 | ]; |
72 | 72 | }, |
73 | + styles () { | |
74 | + const style = {}; | |
75 | + if (this.offset && this.offset.length === 2) { | |
76 | + style['margin-top'] = `${this.offset[0]}px`; | |
77 | + style['margin-right'] = `${this.offset[1]}px`; | |
78 | + } | |
79 | + return style; | |
80 | + }, | |
73 | 81 | finalCount () { |
74 | 82 | if (this.text !== '') return this.text; |
75 | 83 | return parseInt(this.count) >= parseInt(this.overflowCount) ? `${this.overflowCount}+` : this.count; | ... | ... |