Skip to content

Instantly share code, notes, and snippets.

@petervmeijgaard
Last active July 15, 2021 18:57
Show Gist options
  • Save petervmeijgaard/fa8fb655757686db3b63b8c8bc098a67 to your computer and use it in GitHub Desktop.
Save petervmeijgaard/fa8fb655757686db3b63b8c8bc098a67 to your computer and use it in GitHub Desktop.
Writing Reusable Vue Composables - Introduction - Options API
<template>
<div>
<p>My Number - {{ myNumber }}</p>
<p>Parent Number - {{ parentNumber}} - {{ parentNumberPlusOne }}</p>
<button @click="addNumber()">
Add
</button>
</div>
</template>
<script>
export default {
name: 'AsOptionsApi',
props: {
parentNumber: {
type: Number,
required: true,
},
},
data() {
return {
myNumber: 1,
};
},
methods: {
addNumber() {
this.myNumber += 1;
},
},
computed: {
myNumberPlusOne() {
return this.parentNumber + 1;
},
},
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment