refactor(components): [badge] switch to script-setup syntax (#6068)

This commit is contained in:
bqy 2022-02-16 15:18:02 +08:00 committed by GitHub
parent 7034c72151
commit 944deebd8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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>