LardinoisJosse
LardinoisJosse

Reputation: 403

Is it possible to reload only a certain compontent in Vue.js?

I was wondering if I have a Vue component, which has other components in it. Is it possible to only load a certain component.

So If I would have a component like this:

Main component

<template>
<button>Button<button>
<component1></component>
<component2></component2>
</template>

Is it possible to only reload component 1 on click of button 1? If so how would I only reload that certain component?

Thanks in advance!

Upvotes: 0

Views: 151

Answers (1)

wittgenstein
wittgenstein

Reputation: 4482

here is a good article about forcing an update for a component: https://michaelnthiessen.com/force-re-render/

So basically you add a :key to your component and increment a number by clicking your button

<component1 :key="num" />

<button @click="num++" v-text="'update'" />

Upvotes: 1

Related Questions