Answer the question
In order to leave comments, you need to log in
How to call from a component to another vue component?
Hello. Tell me a moment. Maybe he hasn't reached the dock yet, or missed it. I am new to Vue. There is such an example. Page. It has 2 components. On load, the first one is rendered.
<template>
<div class="wrapper">
<div class="component-wrapper1" v-if="oneActive">
<Component1 />
</div>
<div class="component-wrapper2" v-if="twoActive">
<Component2 />
</div>
</div>
</template>
<script>
export default {
name: "test",
data() {
return {
oneActive: true,
twoActive: false,
}
},
Answer the question
In order to leave comments, you need to log in
Option 1 . Events : on the button, the component emits an event. The “page” listens to it and switches its data.
<!-- template компонента -->
<button @click="this.$emit('buttoned')">не нажимать</button>
<!-- template страницы -->
<Component1 v-on:buttoned="triggerComponents" />
<!-- надо написать метод triggerComponents(), который поменяет данным true/false -->
oneActive, twoActive
not in data
, but in state globally available store
. Run mutations on buttons from components .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question