Safari浏览器无法正常运行我的代码?

时间:2020-02-07 18:08:39

标签: javascript html class safari

我有以下课程:

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

我该如何解决?

1 个答案:

答案 0 :(得分:0)

Class field declarations are not finalised,因此我想Safari尚不支持它们。 – VLAZ 3分钟前

所有需要的是:

4: tools::checkMD5sums(pkgname, file.path(tmpDir, pkgname))
3: unpackPkgZip(foundpkgs[okp, 2L], foundpkgs[okp, 1L], lib, libs_only, 
       lock)
2: .install.winbinary(pkgs = bins, lib = lib, contriburl = contrib.url(repos, 
       type2), method = method, available = av2, destdir = destdir, 
       dependencies = NULL, libs_only = libs_only, quiet = quiet, 
       ...)
1: install.packages("plotly")