In the past, Vue 2 allowed us to easily filter items using the |
and filters
syntax. However, this method is no longer supported in Vue 3.
Instead, we now use the "computed" property to transform a single value into another. But what about changing values within an array?
In Vue 2
<template>
<ul>
<li v-for="(index,value) in array1" :key="index">
{{ value | valuefilter}}
</li>
</ul>
</template>
<script>
...
export {
...
filters:{
valuefilter(value){
return '$'+ value
}
}
...
}
</script>