1

I am in the process of upgrading a project to Vue 1.0. I have an array of objects in the following format:

data: {
shifts: {
 '43' : {
 userId: 43,
 name: 'Frank'
 },
 '90' : {
 userId: 90,
 name: 'Martha'
 }
 }
}

Prior to 1.0, to remove an object, I would use this.shifts.$delete('90') to delete that object. This no longer works and it is unclear to me what the replacement is. I have also tried this.$remove(this.shifts, '90'), Vue.$remove(this.shifts, '90'), etc.

Also, $add was deprecated in favor of $set but I cannot figure out how to add a new object (such as '95: { userId: 95, name: 'John' }) with $set.

Very frustrating, any help would be appreciated.

asked Nov 18, 2015 at 19:07

1 Answer 1

3

You could try this,

// to set
Vue.set(this.shifts, '95', {userId: 95, name: 'John'})
// to delete
Vue.delete(this.shifts, '95')

http://codepen.io/pespantelis/pen/PPLJKP

answered Nov 18, 2015 at 19:53
Sign up to request clarification or add additional context in comments.

1 Comment

Ahh you beat me to it by a matter of seconds ;) Apparently I overlooked this in the docs - especially the part where a $ is no longer part of it. Thanks!

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.