vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

Duplicate objects are not supported in v-repeat. #369

Open Anshul-Batra opened 9 years ago

Anshul-Batra commented 9 years ago

Hi ,

I am getting below warning in my application:

[Vue warn]: Duplicate objects are not supported in v-repeat.

Could you please tell me what does this warning means and what are possible reasons for this error. Because of this warning i am getting error el is null and my page doesn't get load.

i am getting this error only in mozilla firefox... In chrome it is working fine.

Anshul-Batra commented 9 years ago

@yyx990803

Hi Evan,

Please let me know the reason for the same

Thanks, Anshul

simplesmiler commented 9 years ago

@Anshul-Batra could you please prove a demo of this working in chrome but breaking in firefox? You can start from this: https://jsfiddle.net/simplesmiler/9zegjc4g/13/ (vue@0.12.12).

Anshul-Batra commented 9 years ago

Hi @simplesmiler ,

our is a very big project splitted in multiple files and that too is client confidential... Cannot disclose. Also, i don't know in which part i am getting error.. otherwise i could have posted that part only.. If you could tell me the possible reasons for this error, it will help me to figure out the solutions.

Thanks, Anshul

nirazul commented 9 years ago

I've come across this error several times. And every time there was a problem with the underlying data-structure. Either you have a track-by id that is used (= in your data) twice, or you don't use track-by and you iterate over a list of objects in which an object is referenced twice.

Anshul-Batra commented 9 years ago

I am not using track-by in my application and i have check my object on which i am doing v-repeat but there is no duplicate object... could you please tell me how to figure it out

simplesmiler commented 9 years ago

@Anshul-Batra you'll have to pinpoint the issue yourself. I suggest making a separate branch, and gradually removing component by component until there's no warning in the console. The last component you would have removed is the problematic one.

hedefalk commented 9 years ago

+1

I got this message:

[Vue warn]: Duplicate objects found in v-repeat="rows": {"result":"success","kcal":{"carbs":20.721797323135753,"fibres":0,"protein":29.498087954110897,"total":164.29732313575525,"fat":114.0774378585086,"alcohol":0},"totalWeight":60,"ingredientText":"1 st korv","kJ":{"carbs":86.69999999999999,"fibres":0,"protein":123.42,"total":687.4200000000001,"fat":477.3,"alcohol":0},"grams":{"carbs":5.1,"fibres":0,"protein":7.26,"total":25.259999999999998,"fat":12.9,"alcohol":0},"maxKcal":"largestCellKcal"}

when the real issue was that I had a watch that blew (findLargestKcalCell wasn't in scope):

  created: () ->
    @$watch(
        () -> @rows,
        (newVal, oldVal) -> largestCellKcal = findLargestKcalCell(newVal)
      )

I got no message pointing to this code, but this error message + a few others like: "Cannot read property '__v_trans' of null" and "Uncaught Error: [vue] async stack trace" from vue internals.