我有模特...
class FormulaModel {
public productType: string;
public tone: string;
public peroxide: string;
public timing: string;
public levels: string;
}
除最后一个属性外,所有属性均使用函数返回结果。
viewModel.stepOne = {
productType: productTypeResult,
peroxide: this.peroxide((formulaValue.startingLevel() + 1),(formulaValue.endingLevel() + 1), serviceType.porosity(), serviceType.texture(), productType, serviceType.gray()),
timing: this.timing(serviceType.gray(), serviceType.texture(), serviceType.porosity(), productType,(formulaValue.endingLevel() + 1)),
tone: this.tone((formulaValue.endingLevel() + 1),(formulaValue.startingLevel() + 1), serviceType.porosity(), serviceType.texture(), formulaValue.endingTone(), serviceType.gray(), productType),
levels: this.levelsTones
};
因为音频函数实际上会计算音频和电平,所以我希望可以创建一个变量levelTones,并在音频函数中将值分配给levelTones变量。
好吧,这不起作用:-(它确实将值分配给变量,但是当我去将变量分配给viewmodel.stepOne时,我得到了一个错误。
有没有办法使这项工作?
最佳答案
为了使它起作用,我只需创建一个返回分配的变量的函数即可。
public levelsAndTones() {
return this.levelsTones;
}