我想在函数/类中使用"this“关键字的析构。
我有这样的代码:
class Test {
constructor( options ) {
let {title, content} = options;
}
}输出是(我正在使用babel ):
var _options = options;
var title = _options.title;
var content = _options.content;如何实现此输出:
this._options = options;
this.title = _options.title;
this.content = _options.content;发布于 2015-09-08 08:05:43
class Test {
constructor( options ) {
({title: this.title, content: this.content} = options);
}
}如果您需要额外的this._options -只需手动分配它。
https://stackoverflow.com/questions/32452179
复制相似问题