How to filter items in Vue 3?

In Vue 2, we filter items conveniently just using | and filters. But it isn’t in Vue 3.

As we know,we can just use "computed" to change a value to another.

But how can I change values of an array?

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>

31 thoughts on “How to filter items in Vue 3?”

Leave a Comment