我为我的 js 使用对象文字,在下面你可以看到它是“全局”变量。其中之一是一个对象(theBody),它又包含一个称为“body”的数组。该数组包含多个对象(以下示例中只有一个),它们是 svg 对象。
我希望能够从名为 bodyColor 的特定变量分配填充值,但是当我更改时:
'fill':'#e59225',
到
'fill': AvGen.theBody.bodyColor,
我收到错误Uncaught ReferenceError: theBody is not defined
为什么会这样,如何访问 object 属性的 bodyColor?
来自js:
var AvGen = {
    paper: null,
    theBody: {
        bodies: [
            [0,0,277.9,308.5,{
                type:'path',
                'fill':'#e59225',
                'stroke':'none',
                'stroke-width':'0',
                'fill-opacity':'1',
                'stroke-opacity':'0'
            }],
        ],
        currNr: 1,
        currObj: null,
        bodyColor: '#e59225'
    },
    init: function() {
    }
}