Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!