我在home组件上,当转到登录页面组件时,我回来了
loginForm() {
localStorage.setItem('isLogin' , 'true' )
const data = this.UserLoginForm.value;
console.log(data);
this.user.email = data.email;
this.user.password = data.password;
console.log(this.user);
this.router.navigateByUrl('/home');
}
从登录页面组件到主页组件ngOninit未被触发
ngOnInit() {
let data = localStorage.getItem('isLogin');
console.log(data);
if(data === 'true'){
console.log('working');
this.isLogin = true;
}
}
在整个项目中也实现了延迟加载。