-
-
Save cristofersousa/acd4bc47797eaa2bac04026eb9fc80a1 to your computer and use it in GitHub Desktop.
Computed Basics Example - Vue
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 class="about"> | |
<h1>This is an about page</h1> | |
<ul> | |
<li v-for="banana in filterBanana" :key="banana.id"> | |
{{ banana }} | |
</li> | |
</ul> | |
</div> | |
</template> | |
<script> | |
// @ is an alias to /src | |
export default { | |
name: 'Home', | |
data() { | |
return { | |
frutas: [ | |
{ id: 1, name: 'banana-maca' }, | |
{ id: 2, name: 'banana-prata' }, | |
{ id: 3, name: 'maça' }, | |
{ id: 4, name: 'pera' }, | |
{ id: 5, name: 'uva' }, | |
{ id: 6, name: 'uva2' }, | |
{ id: 7, name: 'pessego' }, | |
{ id: 8, model: 'jaca' }, | |
], | |
}; | |
}, | |
computed: { | |
filterBanana() { | |
const filterFruit = this.frutas.filter(({ name }) => name === 'uva'); | |
return filterFruit; | |
}, | |
}, | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment