Kapitan Teemo
Kapitan Teemo

Reputation: 2164

Vue.set insert an item at a specific index

this is my items object:

items: {
    houses:{
      name: 'Houses',
      url: '/houses',
      icon: 'icon-home',
    },
    users:{
      name: 'Users',
      url: '/users',
      icon: 'icon-people',
    },
}

I use vue.set to add item in my items object:

Vue.set(nav.items, 'agency_home', 
   {name: 'Agency',
   url: '/pages/404',
   icon: 'icon-home'}
)

This code works, it adds it after the users key. However, I want to add it after the the houses key.

Upvotes: 0

Views: 1005

Answers (1)

Daniel
Daniel

Reputation: 35674

Instead of set, you would use the splice array method, which will invoke the update.

Upvotes: 1

Related Questions