Last active
September 19, 2021 16:41
-
-
Save JimYaaa/5fee425e6527ad1f6496492d6cad8444 to your computer and use it in GitHub Desktop.
vue 2 two way binding prop
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
// 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