'Vuejs using v-model binding with listening from child component
You suppose we have this html tag in parent component which i want to observe that from child using v-model:
<textarea v-model="email"></textarea>
like with that:
<template>
<textarea v-model="caption"></textarea>
<print :caption="caption"/>
</template>
<script>
import print from "./print";
export default {
data() {
return {
caption: ''
}
},
components: {
print
}
}
</script>
print child component:
<template>
<p v-html="caption"></p>
</template>
<script>
export default {
props:{
caption : String
},
mounted() {
this.$emit('caption', this.$el.innerText)
}
}
</script>
now after each typing in parent component how can i observe from child parent and show in p tag? this code is not correct and i can't resolve problem?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
