B
B
BonBon Slick2017-10-24 17:07:42
Vue.js
BonBon Slick, 2017-10-24 17:07:42

Vue remove items from array?

There is an array, for example, of 100 elements, they can be repeated.

[
{id: 1, name: Tester},
{id: 2, name: Tester 2},
{id: 1, name: Tester},
{id: 3, name: Tester 3},
{id: 1, name: Tester},
{id: 4, name: Tester 4},
{id: 5, name: Tester 5},
....
]


HTML
<ul  >
                <li  v-for="(app, index) in userList"
                    :key="index">
                        <span :data-id="user.id"
                             :alt="user.name"
                             :data-pos="index">
                          {{ user.name }} 
                       </span>
                </li>
            </ul>


I do not understand how to leave only a specific gap. Let's say I need a user who has index 24 in the list, I leave it and the next 2-3 users, and delete all the others before and after.

How to do this in Vue.js, please tell me?

Filters? Computed? Function and pure JS? jQuery? By key, index or user.id?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2017-10-24
@BonBonSlick

v-for="(user, index) in userList.slice(24, 26)"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question