Extract value formatting to computed property
This commit is contained in:
parent
139b6ec636
commit
427e7e5359
@ -2,11 +2,18 @@
|
||||
import { defineComponent } from "vue";
|
||||
|
||||
export default defineComponent({
|
||||
props: ["value"]
|
||||
props: ["value"],
|
||||
computed: {
|
||||
formattedValue() {
|
||||
return this.value.toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span :class="value < 0 ? 'negative' : ''">{{value.toLocaleString(undefined, {minimumFractionDigits: 2,})}} €</span>
|
||||
<span class="text-right" :class="value < 0 ? 'negative' : ''">{{formattedValue}} €</span>
|
||||
</template>
|
Loading…
x
Reference in New Issue
Block a user