我不知道这段代码有什么问题
class CatMusicPlayer {
constructor(url,playPauseBtn,progressbar,progressTime,durationTime) {
this.url = url;
this.playPauseBtn = playPauseBtn;
this.progressbar = progressbar;
this.progressTime = progressTime;
this.durationTime = durationTime;
const _thisMP = this;
new Media(url,null,this.logerror,function(mediaStatus){
_thisMP.progressbar(); // call here
/*
i want to use this.progressbar,
but in this block "this" reffers to Media class.
Media is kind of another class similar to CatMusicPlayer
*/
});
}
这给出了语法错误,但我认为语法是正确的。有人可以帮忙吗? 谢谢。
答案 0 :(得分:8)
由于automatic semicolon insertation (ASI),您将返回undefined
。
return // colon is inserted here
{ // never reached
job1: task1,
job2: task2
};
您可以将括号移动到return语句的行中。
return {
job1: task1,
job2: task2
};