NgOnit()未触发

时间:2019-07-01 11:59:27

标签: typescript angular8

我在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;
        }
       }

在整个项目中也实现了延迟加载。

0 个答案:

没有答案
相关问题