Skip to content

Instantly share code, notes, and snippets.

@BenderV
Created December 2, 2020 09:23
Show Gist options
  • Save BenderV/7d51559f872e2acf71c906ff112e323a to your computer and use it in GitHub Desktop.
Save BenderV/7d51559f872e2acf71c906ff112e323a to your computer and use it in GitHub Desktop.
option-api.vue
<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