Answer the question
In order to leave comments, you need to log in
How to prevent multiple instances of components from running?
If the method is called a second time, then a copy of the component will be created, how to prevent this?
<div id="app">
<component v-bind:is="currentComponent"></component>
</div>
new Vue({
el: "#app",
name: 'root',
data: function () {
return {
currentComponent: 'game-start-view'
}
},
methods: {
getLevel() {
this.currentComponent = "game-level";
},
getGame() {
this.currentComponent = "game-agreement";
},
stopGame() {
this.currentComponent = "game-start-view";
}
}
});
Answer the question
In order to leave comments, you need to log in
You are some kind of hardcore, but what prevents you from doing this with different components initially and attaching everything to v-if and displaying the one you need, well, or make similar logic with slots
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question