File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 719719 "name" : " Badge" ,
720720 "cName" : " 徽标" ,
721721 "desc" : " 徽标" ,
722+ "setup" : true ,
722723 "author" : " liqiong"
723724 },
724725 {
Original file line number Diff line number Diff line change 1+ <template >
2+ <view class =" nut-badge" >
3+ <view v-show =" !hidden && !dot && $slots.icon" class =" nut-badge__icon" :style =" style" >
4+ <slot name =" icon" ></slot >
5+ </view >
6+ <slot ></slot >
7+ <view
8+ v-show =" !hidden && (content || dot)"
9+ class =" nut-badge__content nut-badge__content--sup"
10+ :class =" { 'nut-badge__content--dot': dot, 'nut-badge__content--bubble': !dot && bubble }"
11+ :style =" style"
12+ >
13+ {{ content }}
14+ </view >
15+ </view >
16+ </template >
17+
18+ <script setup lang="ts">
19+ import { computed } from ' vue'
20+
21+ defineOptions ({
22+ name: ' NutBadge'
23+ })
24+
25+ export type BadgeProps = Partial <{
26+ value: string | number
27+ max: number
28+ dot: boolean
29+ bubble: boolean
30+ hidden: boolean
31+ top: string
32+ right: string
33+ zIndex: number
34+ color: string
35+ }>
36+
37+ const props = withDefaults (defineProps <BadgeProps >(), {
38+ max: 10000 ,
39+ dot: false ,
40+ bubble: false ,
41+ hidden: false ,
42+ top: ' 0' ,
43+ right: ' 0' ,
44+ zIndex: 9 ,
45+ color: ' '
46+ })
47+
48+ const style = computed (() => {
49+ return {
50+ top: ` ${props .top }px ` ,
51+ right: ` ${props .right }px ` ,
52+ zIndex: props .zIndex ,
53+ background: props .color
54+ }
55+ })
56+
57+ const content = computed (() => {
58+ if (props .dot ) return
59+ const value = props .value
60+ const max = props .max
61+ if (typeof value === ' number' && typeof max === ' number' ) {
62+ return max < value ? ` ${max }+ ` : value
63+ }
64+ return value
65+ })
66+ </script >
Original file line number Diff line number Diff line change 1+ <template >
2+ <view class =" nut-badge" >
3+ <view v-show =" !hidden && !dot && $slots.icon" class =" nut-badge__icon" :style =" style" >
4+ <slot name =" icon" ></slot >
5+ </view >
6+ <slot ></slot >
7+ <view
8+ v-show =" !hidden && (content || dot)"
9+ class =" nut-badge__content nut-badge__content--sup"
10+ :class =" { 'nut-badge__content--dot': dot, 'nut-badge__content--bubble': !dot && bubble }"
11+ :style =" style"
12+ >
13+ {{ content }}
14+ </view >
15+ </view >
16+ </template >
17+
18+ <script setup lang="ts">
19+ import { computed } from ' vue'
20+
21+ defineOptions ({
22+ name: ' NutBadge'
23+ })
24+
25+ export type BadgeProps = Partial <{
26+ value: string | number
27+ max: number
28+ dot: boolean
29+ bubble: boolean
30+ hidden: boolean
31+ top: string
32+ right: string
33+ zIndex: number
34+ color: string
35+ }>
36+
37+ const props = withDefaults (defineProps <BadgeProps >(), {
38+ max: 10000 ,
39+ dot: false ,
40+ bubble: false ,
41+ hidden: false ,
42+ top: ' 0' ,
43+ right: ' 0' ,
44+ zIndex: 9 ,
45+ color: ' '
46+ })
47+
48+ const style = computed (() => {
49+ return {
50+ top: ` ${props .top }px ` ,
51+ right: ` ${props .right }px ` ,
52+ zIndex: props .zIndex ,
53+ background: props .color
54+ }
55+ })
56+
57+ const content = computed (() => {
58+ if (props .dot ) return
59+ const value = props .value
60+ const max = props .max
61+ if (typeof value === ' number' && typeof max === ' number' ) {
62+ return max < value ? ` ${max }+ ` : value
63+ }
64+ return value
65+ })
66+ </script >
Original file line number Diff line number Diff line change @@ -57,6 +57,17 @@ app.use(Badge)
5757| default | Default slot |
5858| icon | Icon slot |
5959
60+ ### Types version
61+
62+ The component exports the following type definitions:
63+
64+ ``` js
65+ import type {
66+ BadgeProps ,
67+ BadgeInstance
68+ } from ' @nutui/nutui'
69+ ```
70+
6071## Theming
6172
6273### CSS Variables
Original file line number Diff line number Diff line change @@ -57,6 +57,17 @@ app.use(Badge)
5757| default | 徽标包裹的子元素 |
5858| icon | 徽标自定义 |
5959
60+ ### 类型定义 version
61+
62+ 组件导出以下类型定义:
63+
64+ ``` js
65+ import type {
66+ BadgeProps ,
67+ BadgeInstance
68+ } from ' @nutui/nutui'
69+ ```
70+
6071## 主题定制
6172
6273### 样式变量
Original file line number Diff line number Diff line change @@ -57,6 +57,17 @@ app.use(Badge)
5757| default | 徽标包裹的子元素 |
5858| icon | 徽标自定义 |
5959
60+ ### 类型定义 version
61+
62+ 组件导出以下类型定义:
63+
64+ ``` js
65+ import type {
66+ BadgeProps ,
67+ BadgeInstance
68+ } from ' @nutui/nutui-taro'
69+ ```
70+
6071## 主题定制
6172
6273### 样式变量
Original file line number Diff line number Diff line change 1+ import Badge from './badge.taro.vue'
2+ import type { ComponentPublicInstance } from 'vue'
3+ import { withInstall } from '@/packages/utils'
4+
5+ withInstall ( Badge )
6+
7+ export type { BadgeProps } from './badge.taro.vue'
8+
9+ export type BadgeInstance = ComponentPublicInstance & InstanceType < typeof Badge >
10+
11+ export { Badge , Badge as default }
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import Badge from './badge.vue'
2+ import type { ComponentPublicInstance } from 'vue'
3+ import { withInstall } from '@/packages/utils'
4+
5+ withInstall ( Badge )
6+
7+ export type { BadgeProps } from './badge.vue'
8+
9+ export type BadgeInstance = ComponentPublicInstance & InstanceType < typeof Badge >
10+
11+ export { Badge , Badge as default }
You can’t perform that action at this time.
0 commit comments