Browse Source

fix: ng 17 current async

ryanemax 9 months ago
parent
commit
945afd0976
1 changed files with 9 additions and 6 deletions
  1. 9 6
      src/modules/user/mine/mine.page.ts

+ 9 - 6
src/modules/user/mine/mine.page.ts

@@ -8,15 +8,18 @@ import * as Parse from "parse"
 })
 export class MinePage implements OnInit {
 
-  // 由于Parse.User.current()是随着localStorage变化的属性
-  // 为了避免首次复制后用户状态变化,页面不同步,通过get方法实现实时获取
-  get user():Parse.User|undefined{
-    return Parse.User.current()
-  }
   constructor() {
+   
   }
 
-  ngOnInit() {
+  // 由于Parse.User.current()是随着localStorage变化的属性
+  // 为了避免首次复制后用户状态变化,页面不同步,通过get方法实现实时获取
+  user:Parse.User|undefined
+  async ngOnInit() {
+      this.user = await Parse.User.current()
+      setInterval(async ()=>{
+      this.user = await Parse.User.current()
+    },1000)
   }
   logout(){
     Parse.User.logOut();