亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從第三方庫訪問角度分量

如何從第三方庫訪問角度分量

慕絲7291255 2021-05-17 20:18:30
我正在構建通過官方JS SDK使用Deezer播放器的網絡應用。我遇到的問題是我無法從Deezer事件訂閱中訪問我的Angular組件。箭頭函數不了解的上下文this,因此我無法調用組件的方法并將值傳遞給它們。什么是實現這一目標的正確方法?app.component.ts// ...declare var DZ;// ...export class AppComponent implements OnInit {    currentTrack: any = null;    constructor() {}    ngOnInit(): void {        DZ.init({            appId  : '8',            channelUrl : 'https://developers.deezer.com/examples/channel.php',            player : {                onload : this.onPlayerLoaded            }        });    }    onPlayerLoaded() {        DZ.player.playAlbum(302127);        DZ.Event.subscribe('player_position', console.log);        DZ.Event.subscribe('current_track', (response) => {            // I would like to pass response.track to setCurrentTrack() there        });    }    setCurrentTrack(track) {        this.currentTrack = track;    }}index.html// ...<head>    <script type="text/javascript" src="https://e-cdns-files.dzcdn.net/js/min/dz.js"></script></head>// ...
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 134 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號