Skip to content

Instantly share code, notes, and snippets.

@kongkx
Last active December 9, 2020 14:13
Show Gist options
  • Save kongkx/22a7b91a59f89d4372b77f7fa1390765 to your computer and use it in GitHub Desktop.
Save kongkx/22a7b91a59f89d4372b77f7fa1390765 to your computer and use it in GitHub Desktop.
vue v-model for custom component
<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