返回

作用域中的javascript-Angular-变量在订阅信息后未接收到信息

发布时间:2022-05-30 19:52:50 271
# 前端

我有一段从我们自己的服务订阅的代码:

方法 getVideo()

  getVideo() {

    this.watchService.getVideoByVideoString(this.videoId).subscribe(

      (Response) => {

        this.videoData = Response;

        console.log(Response);

      },

      (err) => console.log(err)

    );

  }

通过 OnInit 方法

  ngOnInit() {

    this.getVideo();

    console.log(this.videoData);

}

但万一变量this.videoData当我 console.log 时,它返回为 undefined Oo

我知道这将是一个愚蠢的错误,但有人可以帮助我吗?

谢谢

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(2)
按点赞数排序
用户头像