Vue using custom instructions to bind to multiple dom elements will collectively trigger componentUpdated hooks

<template>
  <div class="entry">
    <input type="text" v-test v-model="a" id="a">
    <input type="text" v-test v-model="b" id="b">
  </div>
</template>

<script>
  export default {
    name: "entry",
    data () {
      return {
        a: 1,
        b: 2
      }
    }
    directives: {
      test: {
        componentUpdated (el) {
          console.log(el)
        }
      }
    }
  }
</script>

code as above, typing in any input box triggers componentUpdated , so the corresponding el is printed twice. The official document also says that the VNode of the component where the componentUpdated: directive is located and its child VNode are all updated and called. , my understanding is: which element is bound to, it is called when the corresponding element and its child elements are updated. Two input are sibling elements, so updating one should not affect the other, or there is something wrong with my understanding. Look at the correction.

Mar.06,2021

the update here is only the update, of the whole component. Although in the end, it only updates an input, but it actually triggers the update function of your entry component


.

encountered the same problem.
changing the value of one of them will trigger all instruction binding dom

how can I tell the difference?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3611e-4d681.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3611e-4d681.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?