I am a vuejs newbie, what i want to do may be simple but it seems too complicated to me. Example: What I wrote in the "vue-search" input makes a search in the VueSearch Component, but suddenly it empties the input. and "async search(event)"
I want to send the incoming data to the main component. because I will post there, I will put it in the "getData:[]" section of the main component.
Thank you in advance for your help.
<template>
<vue-search v-model="nameText"/>
</template>
<script>
import VueSearch from "./components/tools/VueSearch";
export default {
data() {
return {
nameText: '',
getData:[]
}
},
components: {
VueSearch
}
}
</script>
<template>
<div>
<input type="text" :value="value" @input="search"/>
<p>{{ DoubleDATA }} </p>
</div>
</template>
<script>
export default {
name: "VueSearch",
data() {
return {
DoubleDATA: ''
}
},
props: {
value: String
},
methods: {
async search(event) {
if (event.target.value !== '') {
const res = await this.callApi('get', 'search' + '?filter=' + event.target.value)
if (res.status === 200) {
this.DoubleDATA = res.data;
}
}
}
}
}
</script>