How to filter and display the user in the component by ID?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
10 views
There is a component with a list of employees.If you click on the employee, it opens the component editor and give it the id of the employee.A comparison filter id, schnick. How to do filtering?
{{worker.name}}export default { created () { this.$store.dispatch('getWorkers') }, data () { return { id: this.$route.params['id'] } }, computed: { workers () { return this.$store.state.workers }, filteredWorker (id) { return this.$store.state.workers.filter(worker => worker.id === id) } } }
by | 10 views

1 Answer

0 like 0 dislike
The code shown you some unconvincing mess, as though they were cut of pieces of code in two different components (list and list item), so I have no idea what you got there, and how it really works, the exact answer do not wait. If the code is real - then you are something in this life specifically don't understand.

Well, the very calculated property filteredWorker - no id as a parameter should not be, to compare the worker.id need to c this.id (of course, if filteredWorker and id from the data are in the same component). Once the comparison is done by id, probably, it is assumed that the result is a single object, why use the filter method? There are also find.
by

Related questions

0 like 0 dislike
1 answer
asked May 22, 2019 by rusline18
0 like 0 dislike
2 answers
asked May 21, 2019 by myskypesla
0 like 0 dislike
1 answer
asked Apr 14, 2019 by Sashjkeee
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
36,634 users