D
D
DrunkMaster2017-03-18 23:23:33
Vue.js
DrunkMaster, 2017-03-18 23:23:33

How to filter by one field in Vue?

I made the code https://jsfiddle.net/wwqy9a5p/1/
I would like it to search only by the name field and if you enter any number, 11, for example, then nothing was found.
The problem is clearly in the line
<li v-for="array in filterBy(arrays, input)">
. But a couple of attempts to fix it, for example, to make arrays.name or arrays, input in name (as in vue 1.0) only led to the script not working.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2019-06-14
@DrunkMaster

The problem is clearly in the line
Yes, you need to add the name of the property you want to filter by as the third parameter.
Or you can do without third-party libraries and format the filtered data as a computed property.
https://jsfiddle.net/jbd5amvo/

Y
Yeldos Adetbekov, 2017-03-19
@dosya97

https://lodash.com/docs/4.17.4#filterBy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question