-3

我正在尝试构建一个基于 jQuery 的简单邮件模板系统。它基本上是一个嵌套数组,应该看起来像:

templates[1] = {
                    "name":"product damage claim",
                    "def":{
                        {'Customer Name?','delivery_name',1},
                        {'Date by which information should be provided by customer?','',1},
                        {'Order ID','orders_id',0}
                    },
                    "tpl":'Mail Content goes here'
};

现在,如果我写上面的内容,javascript 会失败。看来,我在定义对象时做错了def什么,知道什么吗?

4

2 回答 2

1

当您想要一个简单的值列表时,您需要一个数组

"def": [
   ['Customer Name?','delivery_name',1],
   ['Date by which information should be provided by customer?','',1],
   ['Order ID','orders_id',0]
],

现在,这将解决您的句法问题,但这种安排并不能特别容易地提取存储在对象中的内容。

于 2013-08-28T15:10:28.943 回答
1

由于def包含一个值列表,它应该是一个数组数组

templates[1] = {
    "name": "product damage claim",
        "def": [
        ['Customer Name?', 'delivery_name', 1],
        ['Date by which information should be provided by customer?', '', 1],
        ['Order ID', 'orders_id', 0]
    ],
        "tpl": 'Mail Content goes here'
};
于 2013-08-28T15:10:37.813 回答