Created
December 2, 2020 09:23
-
-
Save BenderV/7d51559f872e2acf71c906ff112e323a to your computer and use it in GitHub Desktop.
option-api.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>{{ formattedUserLabel }}</div> | |
<div>{{ counter }}</div> | |
</template> | |
<script> | |
export default { | |
name: "MyComponent", | |
data() { | |
return { | |
// Counter feature | |
counter: 0, | |
// User feature | |
user: { | |
name: "Rudy", | |
lastName: "G." | |
} | |
}; | |
}, | |
methods: { | |
// Counter feature | |
plusOne() { | |
this.counter += 1; | |
} | |
}, | |
computed: { | |
// User feature | |
formattedUserLabel() { | |
return `${this.user.name} - ${this.user.lastName}`; | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment