我正在尝试构建一个基于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
对象时做错了什么,不知道是什么?
答案 0 :(得分:1)
如果需要简单的值列表,则需要数组:
"def": [
['Customer Name?','delivery_name',1],
['Date by which information should be provided by customer?','',1],
['Order ID','orders_id',0]
],
现在,这将解决你的语法问题,但这种安排并不能使提取存储在对象中的东西变得特别容易。
答案 1 :(得分: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'
};