Vue: array.$set removing item from the DOM

Created on 3 Jun 2016  ·  4Comments  ·  Source: vuejs/vue

Vue.js version

1.0.24

Reproduction Link

http://codepen.io/schleumer/pen/NrqGxg

Steps to reproduce

Use array.$set in a multidimensional array with primitive values.

What is Expected?

The value to change and the DOM to update.

What is actually happening?

The value changes, but it's removed from the DOM whilst exists in the array.

bug

Most helpful comment

Looks like a bug to me. In the meantime you can work around it with track-by="$index".

All 4 comments

Looks like a bug to me. In the meantime you can work around it with track-by="$index".

This is not a bug.

[Vue warn]: Duplicate value found in v-for="(column_index, column) in row": -1. Use track-by="$index" if you are expecting duplicate values.

https://github.com/vuejs/vue/blob/dev/src/directives/public/for.js#L658-L667

So, the track-by seems to be the only way to accomplish that.

Thanks for clarifying this, @pespantelis. 👍

@pespantelis you are entirely correct, my bad.

Was this page helpful?
0 / 5 - 0 ratings