Created
August 26, 2018 18:56
-
-
Save cjcrawford/485a742038100ec9e513db3b7a98aa64 to your computer and use it in GitHub Desktop.
Vue Binding Example
This file contains hidden or 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> | |
<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