Skip to content

Instantly share code, notes, and snippets.

@jessuni
Last active January 30, 2022 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessuni/8a848bff21ab3137b00c43b1e82bb340 to your computer and use it in GitHub Desktop.
Save jessuni/8a848bff21ab3137b00c43b1e82bb340 to your computer and use it in GitHub Desktop.
contenteditable-vue-1
<template>
<card v-model="content" />
</template>
<script>
import Card from '...'
export default {
components: { Card },
data() {
return {
content: 'hello world',
}
},
}
</script>
<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