mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-12 10:45:10 +08:00
refactor(components): [badge] switch to script-setup syntax (#6068)
This commit is contained in:
parent
7034c72151
commit
944deebd8d
@ -17,32 +17,25 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent } from 'vue'
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { useNamespace } from '@element-plus/hooks'
|
||||
import { badgeProps } from './badge'
|
||||
|
||||
export default defineComponent({
|
||||
defineOptions({
|
||||
name: 'ElBadge',
|
||||
})
|
||||
|
||||
props: badgeProps,
|
||||
const props = defineProps(badgeProps)
|
||||
|
||||
setup(props) {
|
||||
const ns = useNamespace('badge')
|
||||
const ns = useNamespace('badge')
|
||||
|
||||
const content = computed<string>(() => {
|
||||
if (props.isDot) return ''
|
||||
const content = computed<string>(() => {
|
||||
if (props.isDot) return ''
|
||||
|
||||
if (typeof props.value === 'number' && typeof props.max === 'number') {
|
||||
return props.max < props.value ? `${props.max}+` : `${props.value}`
|
||||
}
|
||||
return `${props.value}`
|
||||
})
|
||||
|
||||
return {
|
||||
ns,
|
||||
content,
|
||||
}
|
||||
},
|
||||
if (typeof props.value === 'number' && typeof props.max === 'number') {
|
||||
return props.max < props.value ? `${props.max}+` : `${props.value}`
|
||||
}
|
||||
return `${props.value}`
|
||||
})
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user