[Vuejs]-Vuejs โ€“ give me a way to select tab and refresh components

0๐Ÿ‘

If you want to re-render/reload a component:

  • call this.$forceUpdate(); on the event onclick on your tab.

Or you can link a variable to your component by using the :key attribute.

<component :key="changingVariable" @click="reRenderComponent()"/>

export default () {
    data() {
        return {
          changingVariable: 0,
        }
      },

      methods: {
        reRenderComponent() {
          this.changingVariable += 1
        }
      }
    }

and everytime you click, the variable will be incremented and vuejs will re render the component linked to changingVariable.

Leave a comment