Photoshop中的类构造函数

问题描述 投票:0回答:1

这应该很简单-在ECMA中创建一个简单的类

class Sandwich
{
  constructor(filling)
  {
    this.sandwichname = filling;
  }
}
mysandwich = new Sandwich("Peanut Butter");

Photoshop说错误9:非法使用保留字'class'第1行。

[我只能确定有一种创建类的方法-如果您原谅这个双关语,就是没有这种类型的构造。

javascript constructor es6-class photoshop-script
1个回答
0
投票

您不能使用此版本的javascript。但是,可以像这样模拟功能:

function Sandwich(filling) {
  this.filling = filling;
}

Sandwich.prototype.someMethod = function() {
  console.log(this.filling);
};

var jelly = new Sandwich("jelly");

jelly.someMethod();
© www.soinside.com 2019 - 2024. All rights reserved.