A
A
Alexander Ivanov2018-02-23 14:56:31
Vue.js
Alexander Ivanov, 2018-02-23 14:56:31

Why are vue search values ​​not being output?

I'm already implementing it for the second time, but now apparently I don't see something somewhere.

<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);
            })
          }
        }
      }
    }
  }

Complains about this:
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...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-02-23
@cimonlebedev

You put computed in data - what kind of nonsense?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question