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