kazupon / vue-validator

:white_check_mark: Validator component for Vue.js
MIT License
2.19k stars 431 forks source link

fields not working right after v-for data changing #273

Closed Jokcy closed 7 years ago

Jokcy commented 8 years ago

vue & vue-validator version

1.0.24, 2.1.3

Reproduction Link

http://jsfiddle.net/v0gk43m4/20/

Steps to reproduce

At first arr is [1,2,3], click the update arr button, turn arr to [2,3,4]. notice that the arr object changed, and the :field seems not working, $validation only contains two fileds

What is Expected?

No matter when and how data changes, fields always should be right.

What is actually happening?

When data changes, fileds not working right

Jokcy commented 8 years ago

@kazupon so when will you fix this bug?

kazupon commented 8 years ago

sorry for my late reply.

I can not see the light at this issue, because I'm developing the vue-validator v3 for vue 2.0.

I checked your jsfiddle code again. I could not understand your codes that to use as index value of arr. vue-validator don't expect dynamically index.

Could you tell me the use-cases ?

nandin-borjigin commented 8 years ago

changeing :field="getField($index) to :field="getField(n)" magically works, though don't know why yet

nandin-borjigin commented 8 years ago

Haha, solved it updated jsfiddle. I think the problem is related to reusability feature of v-for directive. I added a track-by="$index" to the v-for directive's element and the code runs correctly now.

kazupon commented 7 years ago

close (in-activity)