Vue: input lose the focus when list rendering use "v-model" and ":key"

Created on 4 Nov 2016  Â·  1Comment  Â·  Source: vuejs/vue

      <div v-for="(item, index) of value" :key="item.text">
        <input  v-model="item.text" /> 
      </div>

For this example, the item plus a key and use v-model on input of item . The input will lose the focus when keyup ,how to resolve problem ? thanks.

Most helpful comment

Hello!

This is a usage question, and we encourage you to ask it on forum or gitter. We try to use the issue tracker for bug reports and feature requests.

As for the question, you are literally recreating the input every time the text is changed. You should give your items identifiers, and key using them instead. As an alternative, you could :key="item" to track items by reference.

>All comments

Hello!

This is a usage question, and we encourage you to ask it on forum or gitter. We try to use the issue tracker for bug reports and feature requests.

As for the question, you are literally recreating the input every time the text is changed. You should give your items identifiers, and key using them instead. As an alternative, you could :key="item" to track items by reference.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gkiely picture gkiely  Â·  3Comments

Jokcy picture Jokcy  Â·  3Comments

loki0609 picture loki0609  Â·  3Comments

franciscolourenco picture franciscolourenco  Â·  3Comments

seemsindie picture seemsindie  Â·  3Comments