Safari 浏览器没有运行 我的代码正常吗?

Safari browser not running my code properly?

我有以下 class:

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;
  }
}

当我在 safari 浏览器上 运行 这个时,我得到了两个波纹管错误。

SyntaxError: Unexpected token '='. Expected an opening '(' before a method's parameter list.

然后尽管 运行 在 main.js 脚本之前为门户 class 设置了脚本,但我得到了这个:

Unhandled Promise Rejection: ReferenceError: Can't find variable: 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;
  }
}