我有以下课程:
class Portal {
caption = "";
thumbnailURL = "";
profileImgURL = "";
mp3 = "";
timestamp = 0.0;
username = "";
uid = "";
num = 0;
// var caption = new String();
// var caption = "";
// var thumbnailURL = "";
// var profileImgURL = "";
constructor(cap, thumb, prof, mp3, timestamp, username, uid) {
this.caption = cap;
this.thumbnailURL = thumb;
this.profileImgURL = prof;
this.mp3 = mp3;
this.timestamp = timestamp;
this.username = username;
this.uid = uid;
}
}
[当我在野生动物园浏览器上运行时,出现两个以下错误。
SyntaxError:意外令牌'='。在方法的参数列表之前应以'('开头。
然后尽管在main.js脚本之前运行了门户网站类的脚本,但我得到了这个:
未处理的承诺拒绝:ReferenceError:找不到变量:Portal
我该如何解决?
Class field declarations are not finalised,所以我认为Safari尚不支持它们。 – VLAZ 3分钟前
所有需要的是:
class Portal {
constructor(cap, thumb, prof, mp3, timestamp, username, uid) {
this.caption = cap;
this.thumbnailURL = thumb;
this.profileImgURL = prof;
this.mp3 = mp3;
this.timestamp = timestamp;
this.username = username;
this.uid = uid;
}
}