I'm stuck in -maybe- logic usage of Vue, I have a "list" component which get results from ajax, the problem appears when I want to add a search field, I have something like this:
search.vue
<template>
<div>
<div v-for="(result, index) in results">
<h2>{{ result.name }}</h2>
</div>
</div>
</template>
<script>
export default {
name : 'searchList',
data() {
return { results: [] }
}
created: function(){
this.goSearch();
},
methods : {
goSearch : function(){
this.results = axios.get('/search');
}
}
}
</script>
This works like a charm, the point is that I want to add an input to search, I've made some research and I've found that the only way to get this is using another component, but I don't want to create another component just for an input, so I want to do something like:
index.html
<input type="text" v-model="goSearch">
<search-list></search-list>
But the problem that I'm facing is that Vue is returning an error:
[Vue warn]: Property or method "goSearch" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
I've also tried with v-bind="goSearch" but doesn't work either. Any ideas to accomplish this?
UPDATE: I've created a button to call the function:
<button @click="goSearch"></button>
The function "goSearch" now tries to get the value from the text box, but also this doesn't work.

createdandmethodskeys are out of the exported object. Do not you get a parse error?