Skip to content

Commit

Permalink
fix: number format type error
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Oct 31, 2023
1 parent 9a1c9b7 commit c1db1d8
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions src/views/dashboard/statistic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@ import { defineComponent } from 'vue'
export const Statistic = defineComponent({
props: { label: String, value: [String, Number] },
setup(props) {
return () => (
<Fragment>
{props.value === 'N/A' ? (
<NSpace vertical align="center" class="min-h-[4rem]">
<NSkeleton style={{ height: '.8rem', width: '5rem' }}></NSkeleton>
<NSkeleton style={{ height: '1.8rem', width: '3rem' }}></NSkeleton>
</NSpace>
) : (
<NStatistic
label={props.label}
value={Intl.NumberFormat('en-us').format(props.value)}
tabularNums
></NStatistic>
)}
</Fragment>
)
return () => {
const value = props.value
return (
<Fragment>
{props.value === 'N/A' ? (
<NSpace vertical align="center" class="min-h-[4rem]">
<NSkeleton style={{ height: '.8rem', width: '5rem' }}></NSkeleton>
<NSkeleton
style={{ height: '1.8rem', width: '3rem' }}
></NSkeleton>
</NSpace>
) : (
<NStatistic
label={props.label}
value={
typeof value === 'string'
? value
: typeof value === 'undefined'
? ''
: Intl.NumberFormat('en-us').format(value)
}
tabularNums
></NStatistic>
)}
</Fragment>
)
}
},
})

0 comments on commit c1db1d8

Please sign in to comment.