Answers for "vue js hooks"

45

vue lifecycle hooks

<script>
  export default {
    beforeCreate() {
      console.log("beforeCreate")
    },
    created() {
      console.log("created")
    },
    beforeMount() {
      console.log("beforeMount")
    },
    mounted() {
      console.log("mounted")
    },
    beforeUpdate() {
      console.log("beforeUpdate")
    },
    updated() {
      console.log("updated")
    },
    beforeDestroy() {
      console.log("beforeDestroy")
    },
    destroyed() {
      console.log("destroyed")
    }
  }
</script>
Posted by: Guest on June-07-2020
0

vue js hooks

beforeUpdate(){
///beforeUpdate: Called when data changes, before the DOM is patched
}

mounted() {
  this.$nextTick(function () {
    // Code that will run only after the
    // entire view has been rendered
  })
}

updated() {
  this.$nextTick(function () {
    // Code that will run only after the
    // entire view has been re-rendered
  })
}
//others are
//beforeUpdate : Called when data changes, before the DOM is patched. 
//activated : Called when a kept-alive component is activated.
// deactivated : Called when a kept-alive component is deactivated.
// beforeUnmount : Called right before a component instance is unmounted. At this stage the instance is still fully functional.
// unmounted : Called after a component instance has been unmounted.
Posted by: Guest on November-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language