Skip to content

Instantly share code, notes, and snippets.

@JimYaaa
Last active September 19, 2021 16:41
Show Gist options
  • Save JimYaaa/5fee425e6527ad1f6496492d6cad8444 to your computer and use it in GitHub Desktop.
Save JimYaaa/5fee425e6527ad1f6496492d6cad8444 to your computer and use it in GitHub Desktop.
vue 2 two way binding prop
// ChildComponent.vue
<script>
export default {
props: {
title: {
type: String,
default: 'Default title'
}
},
methods: {
changeTitle() {
this.$emit('update:title', 'new title')
}
}
}
</script>
// ParentComponent.vue
<template>
<ChildComponent :title="pageTitle" @update:title="pageTitle = $event" />
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment