Answer the question
In order to leave comments, you need to log in
How to make the authorization form stop blinking?
I am creating a simple Vue.js application. There is a component like this
<div id="app">
<template v-if="auth === true">
ТУТ ОСНОВНОЙ КОНТЕНТ
</template>
<template v-else>
ФОРМА АВТОРИЗАЦИИ
</template>
</div>
<script>
...
data: function () {
return {
auth: false
}
},
created() {
this.checkUser();
},
methods: {
checkUser: function () {
...
Тут проверка пользователя на авторизацию и в случае успеха:
this.auth = true;
...
}
}
...
</script>
Answer the question
In order to leave comments, you need to log in
Add a third state, it is also default - uncertainty, it is not clear whether the user is authorized or not:
data: () => ({
auth: null,
}),
methods: {
checkUser() {
...
// указываем false только в случае отрицательного результата проверки
this.auth = false;
...
},
},
<template v-else-if="auth === false">
ФОРМА АВТОРИЗАЦИИ
</template>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question