Skip to content

Instantly share code, notes, and snippets.

@VisionYi
Last active December 31, 2020 14:56
Show Gist options
  • Save VisionYi/6f2475f6282ab3e345772a39fd515dce to your computer and use it in GitHub Desktop.
Save VisionYi/6f2475f6282ab3e345772a39fd515dce to your computer and use it in GitHub Desktop.
<template>
name: <input type="text" v-model="nameSync">
year: <input type="number" v-model="yearSync">
</template>
<script>
export default {
//...
props: {
name: {
type: String,
default: '',
},
year: {
type: Number,
default: 0,
},
},
computed: {
nameSync: {
get() {
return this.name
},
set(value) {
this.$emit('update:name', value)
}
},
yearSync: {
get() {
return this.year
},
set(value) {
this.$emit('update:year', value)
}
},
},
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment