Skip to content

Instantly share code, notes, and snippets.

@frankyonnetti
Last active February 17, 2021 00:27
Show Gist options
  • Select an option

  • Save frankyonnetti/0dd25ba390e32bb6ac793af134ed2770 to your computer and use it in GitHub Desktop.

Select an option

Save frankyonnetti/0dd25ba390e32bb6ac793af134ed2770 to your computer and use it in GitHub Desktop.
Vue - computed and v-for #vue #v-for
<ul>
<li v-for="item in itemsLessThanTen" :key="item.name">
{{ item.name }} - {{ item.price }}
</li>
</ul>
<script>
export default {
data () {
return {
shoppingItems: [
{ name: 'apple', price: '7' },
{ name: 'orange', price: '12' }
]
}
},
computed: {
itemsLessThanTen () {
return this.shoppingItems.filter((item) => {
return item.price > 10
})
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment