获取对象文字中的属性值

时间:2014-12-09 18:54:28

标签: javascript arrays oop

this.units给了我一个未定义的。我如何访问此值?或者你会以不同的方式设置这一整体吗?也许你们可以帮助我?

var calculator = calculator || {};

(function() {

calculator.sliderValues = {
    applications: 42,
    capacity: 140,
    activeData: 30,
    performance: 30,
    virtualized: 100
}

calculator.overview = {
    apps: {
        HighPerformanceApps: {
            units: Math.ceil(calculator.sliderValues.applications/100 * calculator.sliderValues.performance),
            virtualized: calculator.sliderValues.virtualized < 81 ? 0 : this.units
        }
    }
}

})();

提前致谢

1 个答案:

答案 0 :(得分:-1)

更新2:

CODEPEN

**这是因为this引用了窗口对象`