Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
Will $attrs affect vuejs patch?

I use vuejs to render a list and give each item the correct key. Normally, I delete the first item of the array, and all the sub-items in the list will not be updated.

But I found that when adding a v-bind="$attrs" to the sub-items, when I delete any item, all the sub-items will be updated!

Normal code:

new Vue({
        el: "#app",
        components: {
          Item: {
            props: {
              item: Number
            },
            template: `<input :placeholder="item"></input>`,
            beforeUpdate() {
              console.log('Item beforeUpdate')
            },
            updated() {
              console.log('Item updated')
            }
          }
        },
        data() {
          return {
            list: [1, 2, 3]
          };
        },
        template: `
          <div>
            <button @click="list.splice(0, 1)">splice first</button>
            <item v-for="item in list" :key="item" :item="item" />
          </div>
        `
      });

When the above code is running, i click button, will not print anything. Explain that the sub-items component is not updated.

When i modify the component's template as:

<input :placeholder="item" v-bind="$attrs"></input>

and click button, will print 'Item beforeUpdate' and 'Item updated', this is incorrect in my cognition!

Hope someone who knows this can help me, thank you!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda