Last active
January 30, 2022 10:21
-
-
Save jessuni/8a848bff21ab3137b00c43b1e82bb340 to your computer and use it in GitHub Desktop.
contenteditable-vue-1
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> | |
<card v-model="content" /> | |
</template> | |
<script> | |
import Card from '...' | |
export default { | |
components: { Card }, | |
data() { | |
return { | |
content: 'hello world', | |
} | |
}, | |
} | |
</script> |
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> | |
<div contenteditable="true" @input="update" v-text="modelValue"></div> | |
</template> | |
<script> | |
export default { | |
props: { | |
modelValue: { | |
type: String, | |
default: '', | |
}, | |
}, | |
emits: ['update:modelValue'], | |
methods: { | |
update(e) { | |
this.$emit('update:modelValue', e.target.textContent) | |
}, | |
}, | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment