Skip to content

Instantly share code, notes, and snippets.

@cjcrawford
Created August 26, 2018 18:56
Show Gist options
  • Save cjcrawford/485a742038100ec9e513db3b7a98aa64 to your computer and use it in GitHub Desktop.
Save cjcrawford/485a742038100ec9e513db3b7a98aa64 to your computer and use it in GitHub Desktop.
Vue Binding Example
<template>
<input ref="input" v-model="localValue" @change="handleChange">
</template>
<script>
export default {
data: () => ({
localValue: null
}),
props: ['value'],
methods: {
handleChange ({date}) {
this.$emit('change', date)
}
},
watch: {
value: {
handler (newValue) {
if (newValue !== this.localValue) {
this.localValue = newValue
}
},
immediate: true
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment