how to make v-if when rendering to another component to render fast ? i have some case , when i am going to login and after success my nabvar component doest change after it finished, i should manually reload it on my client to get logout button and it is same also when i delete , i should manually to reload tho i already put :key on that component
here is my component in my login.vue page
goLogin() {
if (!this.input || !this.password) {
this.$swal.fire({
type: 'error',
text: `please enter your email/username and password`,
});
} else {
const client = {
input: this.input,
password: this.password,
};
this.$axios
.post('/api/user/login', client)
.then(({
data
}) => {
localStorage.setItem('token', data.token);
// vm.$forceUpdate();
localStorage.setItem('role', data.tryingLogin.role);
this.$swal.fire({
type: 'success',
text: `successfully login`,
});
if (data.tryingLogin.role === 'admin') {
this.$router.replace({
path: '/admin'
});
} else {
this.$router.push({
path: '/'
});
}
})
.catch(err => {
this.$swal.fire({
type: 'error',
text: err.response.data.error,
});
});
}
and on my Header.vue component, i have isLogin props, and i check by if localStorage.getItem("token") i close the button login and register on navbar header.vue and it should show logout button if client has token, but it was not, after succesfuly login, i should reload it to get the button logout showing
how to force it to be changed quickly ? to swap show and hide button login and logout ??
i also make props to check login on my App.vue and i use all hooks lifecyly to swap login button ans logout , it doesnt changed at all, :(
and it happends when i delete my list also, i should reload it :( i hope you guys could give me some help and trick for solve this problem :D