Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Vue.filter('currencyFilter', (value, currency) => {
return `${value}${currency}`
});
Vue.component('filters', {
data () {
return {
totalAmount: 9.99
}
},
template: `
<div>
<h2>Filtros en Vue 2</h2>
<input v-model="totalAmount" />
<p>Cantidad total: {{ totalAmount | currencyFilter('€') }}</p>
</div>
`
});
app.component("filters", {
setup() {
const totalAmount = ref(9.99);
const totalAmountFormatted = computed(() => {
return `${totalAmount.value}€`;
});
return { totalAmountFormatted };
},
template: `
<h2>Reemplazo de filtros en Vue 3</h2>
<input v-model="totalAmount" />
<p>Cantidad total: {{ totalAmountFormatted }}</p>
`
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment