mine.page.ts 745 B

12345678910111213141516171819202122232425262728
  1. import { Component, OnInit } from '@angular/core';
  2. // 由于Parse本身是js库,在ts中加载需要通过 * as Parse转换一下
  3. import * as Parse from "parse"
  4. @Component({
  5. selector: 'app-mine',
  6. templateUrl: './mine.page.html',
  7. styleUrls: ['./mine.page.scss'],
  8. })
  9. export class MinePage implements OnInit {
  10. constructor() {
  11. }
  12. // 由于Parse.User.current()是随着localStorage变化的属性
  13. // 为了避免首次复制后用户状态变化,页面不同步,通过get方法实现实时获取
  14. user:Parse.User|undefined
  15. async ngOnInit() {
  16. this.user = await Parse.User.current()
  17. setInterval(async ()=>{
  18. this.user = await Parse.User.current()
  19. },1000)
  20. }
  21. logout(){
  22. Parse.User.logOut();
  23. }
  24. }