Last active
December 9, 2020 14:13
-
-
Save kongkx/22a7b91a59f89d4372b77f7fa1390765 to your computer and use it in GitHub Desktop.
vue v-model for custom component
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
<template> | |
<input @input="handleInput" /> | |
</template> | |
<script> | |
export default { | |
props: ['value'], | |
data () { | |
return { | |
content: this.value | |
} | |
}, | |
methods: { | |
handleInput (e) { | |
this.$emit('input', this.content) | |
} | |
} | |
} | |
// export default { | |
// props: ['hidden'], | |
// model: { | |
// prop: 'hidden', | |
// event: 'blur' | |
// } | |
// methods: { | |
// handleInput (value) { | |
// this.$emit('blur', value) | |
// } | |
// } | |
// } | |
/** | |
* <basic-input v-model="email" /> | |
* --> | |
* <basic-input :hidden="email" @blur="e => email = e.target.value" /> | |
*/ | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment