创新实训项目分析(十四)

2021SC@SDUSC
接下来是对Option类的分析
Option类具有一个枚举,用来对基本数据类型进行标识
在这里插入图片描述
Option类具有以下的基础参数
在这里插入图片描述
其中id是进行唯一标识作用
type表示类型
name表示Option的名字
dafault_value表示Option中的默认值
并具有着callback参数进行回调操作
然后具有着onChange参数用来对Option发生变化时进行修改操作
然后进行初始化与get、set

Option.prototype.initialize = function(id, tool_id, type, name, default_value, options, callback) {
  this._id = id;
  this._tool_id = tool_id;
  this._type = type;
  this._name = name;
  this._default_value = default_value;
  this._options = options;
  this._callback = callback;
  this._on_change = this.onChange.bind(this);
}
Object.defineProperty(Option.prototype, 'id', {
  get: function() {
    return this._id;
  },
  configurable: true
});
Object.defineProperty(Option.prototype, 'tool_id', {
  get: function() {
    return this._tool_id;
  },
  configurable: true
});
Object.defineProperty(Option.prototype, 'type', {
  get: function() {
    return this._type;
  },
  configurable: true
});
Object.defineProperty(Option.prototype, 'name', {
  get: function() {
    return this._name;
  },
  configurable: true
});
Object.defineProperty(Option.prototype, 'default_value', {
  get: function() {
    return this._default_value;
  },
  configurable: true
});
Object.defineProperty(Option.prototype, 'options', {
  get: function() {
    return this._options;
  },
  configurable: true
});
Object.defineProperty(Tool.prototype, 'callback', {
  get: function() {
    return this._callback;
  },
  configurable: true
});
Object.defineProperty(Option.prototype, 'on_change', {
  get: function() {
    return this._on_change;
  },
  configurable: true
});

实现onchange方法来进行当id变化时进行执行

Option.prototype.onChange = function(value){
  OptionManager.setValue(this._tool_id, this._id, value);
  if(this._callback) {
    this._callback.call(this);
  }
  Engine.updateEditorOptionData();
};
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值