Второй раз уже реализую но сейчас видимо где-то чего не вижу.
<input type="text" class="search-field" v-model="search" placeholder="Поиск посылок" autofocus />
<p> тут само собой отобразит - {{ search }} </p>
<hr>
<ul id="example-1">
<li v-for="item in filterStore" :key="item.id">
{{ item.id }} {{ item.name }} {{ item.surname }} {{ item.val }}
</li>
</ul>
// -----
export default {
name: 'Search',
data () {
return {
search: '',
posts: [
{
"id": 1,
"name": "Simon",
"surname": "Kamni",
"val": "asdf32"
},
{
"id": 2,
"name": "Arnold",
"surname": "Aebedev",
"val": "234gf"
},
{
"id": 3,
"name": "Lu",
"surname": "Bebedev",
"val": "sd234gf"
}
],
computed: {
filterStore: function () {
return this.posts.filter((post)=>{
return post.name.match(this.search);
})
}
}
}
}
}
Жалуется на это:
Property or method "filterStore" 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://vuejs.org/v2/guide/reactivity.html#Declari...