Last active
July 15, 2021 18:57
-
-
Save petervmeijgaard/fa8fb655757686db3b63b8c8bc098a67 to your computer and use it in GitHub Desktop.
Writing Reusable Vue Composables - Introduction - Options API
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> | |
<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