Answers for "vue re render v-for"

0

vue 3 re render component

<template>
  <component-to-re-render :key="componentKey" />
</template>

export default {
  data() {
    return {
      componentKey: 0,
    };
  },
  methods: {
    forceRerender() {
      this.componentKey += 1;
    }
  }
}
Posted by: Guest on August-12-2021
0

vue re render v-for

<template>
  <my-component v-if="renderComponent" />
</template>

<script>
  export default {
    data() {
      return {
        // Add boolean which decides render or not
        renderComponent: true,
      };
    },
    methods: {
      forceRerender() {
        // Remove my-component from the DOM
        this.renderComponent = false;

        this.$nextTick(() => {
          // Add the component back in
          this.renderComponent = true;
        });
      }
    }
  };
</script>
Posted by: Guest on July-12-2021

Browse Popular Code Answers by Language