The question is how can I pass from the first component (local) value? Those. There are 2 components, if something returns true in the first, it is replaced with v-else, I tried both props and $ emit ($ event), but if successful, nothing happens, please tell me. Code code and here and on codePen
new Vue ({ el: '.container_auth', data: { sing: 'in', } }) Vue.component('up', { data() { return { name: 'sing-in', error: false, user: { email: '', password: '', confirmPassword: '' }, } }, template: ` <form action="" @submit.prevent = "registerUser"> <div class="form-group"> <label for="email">Ваш Email:</label> <input type="email" id='email' placeholder="Введи Email!" v-model="user.email" required> </div> <div class="form-group"> <label for="password">Ваш Пароль (минимум 6 символов)</label> <input type="password" placeholder="Ваш пароль" id="password" v-model="user.password" required> </div> <div class="form-group"> <label for="password2">Повторите Пароль</label> <input type="password" id="password2" placeholder="Повторить пароль" v-model="user.confirmPassword" required> </div> <div class="alert" role="alert" v-if="error"> <strong>Ошибочка!</strong> Пароли не совпадают или вы забили их ввести! </div> <button type="submit" class="btn">Зарегистрироваться!</button> </form> `, methods: { registerUser(){ if(this.user.password != this.user.confirmPassword || this.user.password.length < 6) { this.error = true } else { return firebase.auth().createUserWithEmailAndPassword(this.user.email, this.user.password) .then(() => { // Тут я хочу вернуть не v-if, а v-else. То есть, если запрос прошел, то скрыть компонент <up> }) .catch(function(error) { console.log(error) }) } } }, }) Vue.component('in', { data() { return { error: false, user: { email: '', password: '' } } }, template: ` <form action="" @submit.prevent = "singUp"> <div class="form-group"> <label for="email">Ваш Email</label> <input type="email" id="email" placeholder="Введите Email" v-model="user.email" required> </div> <div class="form-group"> <label for="password">Ваш Пароль</label> <input type="password" id=password placeholder="Ваш Пароль" v-model="user.password" required> </div> <button type="submit" class="btn">Войти</button> </form> `, methods: { singUp(){ firebase.auth().signInWithEmailAndPassword(this.user.email, this.user.password) .then( (response) => { console.log(response) const sett = { email: response.email, uid: response.uid } }) } } })
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div class="container_auth"> <up v-if></up> <in v-else></in> </div>