Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected v-model error #240

Closed
KristofMorva opened this issue Nov 23, 2017 · 4 comments · Fixed by #243 or #638
Closed

Unexpected v-model error #240

KristofMorva opened this issue Nov 23, 2017 · 4 comments · Fixed by #243 or #638

Comments

@KristofMorva
Copy link

KristofMorva commented Nov 23, 2017

The valid-v-model throws an 'v-model' directives cannot update the iteration variable 'x' itself error, even if the iteration variable is not modified (3.14.0).

For example, the following case works perfectly:

v-for="i in 4" v-model="numbers[i]"

However, if we introduce a BinaryExpression, the error above will be produced:

v-for="i in 4" v-model="numbers[i - 1]"

I might be wrong, but I believe this construction should be allowed, as

  • it works
  • the error message does not fit the scenario (iteration variable is not modified)
@michalsnik
Copy link
Member

Thanks for posting this issue @KristofMorva ! I'll look into it :)

@ReynerHL
Copy link

ReynerHL commented Feb 28, 2018

Hi @michalsnik
The same applies to variable interpolations using quoted strings:

v-for="i in 4" v-model="numbers[`${i}`]"
  • it works
  • the error message does not fit the scenario (iteration variable is not modified)

Can you fix this case, please ?

@qkdreyer
Copy link
Contributor

qkdreyer commented Jun 7, 2018

I've just encountered the same issue.

Pseudo code :

<div v-for="(kind, kindIndex) in ['shipping', 'billing']" :key="kindIndex">
  <h3>{{ $t(`delivery.address.${kind}`) }}</h3>
  <hr>
  <address-component :address="$data[`${kind}Address`]"/>
  <select v-model="$data[`${kind}Address`]">
    <option v-for="(address, addressIndex) in addresses" :key="addressIndex" :value="address">
      #{{ addressIndex }} {{ address.street }} {{ address.postcode }} {{ address.city }}
    </option>
  </select>
</div>

@joshfoskett
Copy link

Also experiencing the issue described in the two comments above.

@michalsnik Should this issue be reopened, or a new one created?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants