-
-
Save wilcorrea/42a3510b08270d64f617cb8239e6f5fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function (value) { | |
const formatted = Number(value) | |
.toFixed(2) | |
.replace('.', ',') | |
.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1.") | |
return `R$ ${formatted}` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<p>Product one cost: {{ productOneCost | money }}</p> | |
<p>Product two cost: {{ productTwoCost | money }}</p> | |
<p>Product three cost: {{ productThreeCost | money }}</p> | |
</div> | |
</template> | |
<script> | |
import money from 'formatters/money' | |
export default { | |
data: () => ({ | |
productOneCost: 998, | |
productTwoCost: 2399, | |
productThreeCost: 5300 | |
}), | |
filters:{ | |
money(value){ | |
return money(value) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment