Answer the question
In order to leave comments, you need to log in
Why is state not updated after successful data fetch?
It is necessary to stop displaying the authorization route upon successful login.
Component:
<template>
<div id="app">
<ul>
<li v-if="login">
<router-link to="/tickets">Билеты</router-link>
</li>
<li v-else>
<router-link to="/authorization">Авторизация</router-link>
</li>
</ul>
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'app',
computed: {
login() {
return this.$store.authInfo
}
},
components: {
}
}
</script>
const state = {
authInfo: {}
};
const mutations = {
loginSuccess(state, data) {
console.log(data); // тут объект точно есть.
state.authInfo = {...data}
}
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question