I'm having trouble passing text data from a custom component to the main component. This custom component is text area and I want to store the text the into my database. I tried to use Prop annotation but it didn't work. When I console.log(this.text) I don't see any text data. I may doing this wrong so if anyone could help me out, that would be awesome!
My main component
<template>
<div>
<textarea-component></textarea-component>
<button @click="save()"></button>
<div>
</template>
<script lang=ts>
import {Component, Prop, Vue} from 'vue-property-decorator';
import api from '@/infrastructure/api/noteApi';
@Component({
components: {
'textarea-component': TextAreaComponent,
},
})
export default class MainPage extends Vue {
@Prop
text!: string;
private async save() {
//check if the data is passing
console.log(this.text)
//save to the database
await api.saveText(string)
.then((Response) => {
console.log(Response)
});
}
}
</script>
<template>
<div>
<textarea v-bind:value="text">
</textarea>
</div>
</template>
<script lang=ts>
import {Component, Vue} from 'vue-property-decorator';
@Component
export default class TextAreaComponent extends Vue {
text:string = '';
}
</script>