所以我有这门课:( Math.js)
export default class SomeMath {
construct(value)
{
this.options = value
}
DoSomeMath(val) {
return this.options + val;
}
}
我想匿名称呼它,我可以做到这一点:
import * as ClassesArray from './math.js'
let ClassInString = 'SomeMath';
let MethodInString = 'DoSomeMath';
let TheClass = new ClassesArray.default[ClassInString].default(50), // Hacky way because of babel
TheMethod = TheClass[MethodInString];
TheMethod.call(this, 50); // Wont work.
问题是,this.options
在DoSomeMath
中返回空。有没有办法让这项工作?或者这是es6的限制吗?