Javascript 期待';ID';,得到';编号';
我在Javascript 期待';ID';,得到';编号';,javascript,handlebars.js,Javascript,Handlebars.js,我在json "ICON":{ "144":"https://example.com/bubble-academy.jpg", "228":"https://example.com/bubble-academy.jpg", "72":"https://example.com/bubble-academy.jpg", "152":"https://example.com/bubble-academy.jpg", "130":"https://example.
json
"ICON":{
"144":"https://example.com/bubble-academy.jpg",
"228":"https://example.com/bubble-academy.jpg",
"72":"https://example.com/bubble-academy.jpg",
"152":"https://example.com/bubble-academy.jpg",
"130":"https://example.com/bubble-academy.jpg",
"120":"https://example.com/bubble-academy.jpg",
"32":"https://example.com/bubble-academy.jpg"
}
在把手中,我试图访问属性32
,如下所示
<img src="{{ ICON.32 }}">
我得到以下错误
Module build failed: Error: Parse error on line 5:
..."{{ mediaFiles.ICON.32 }}"> <sp
-----------------------^
Expecting 'ID', got 'NUMBER'
模块构建失败:错误:第5行的分析错误:
…“{mediaFiles.ICON.32}}”>这是因为您使用了一个数字作为属性名,请尝试改用此名称:
这里还有一个让人困惑的有趣案例:
(这就是静态生成的wordpress表单的外观)
此模板将生成空白
<p>Form submission</p>
<p>{{body.input_2.[2]}} {{body.input_2.[3]}} {{body.input_2.[6]}}</p>
<p>{{body.input_6}}</p>
Result:
<p></p>
<p>Professor</p>
表单提交
{{body.input_2.[2]}{{body.input_2.[3]}{{body.input_2.[6]}
{{body.input_6}}
结果:
教授
显然,由于所有的数字项都不存在。。。你不能简单地把它们括起来。。。必须立即将整个子路径分组
Proper template:
<p>Form submission</p>
<p>{{body.[input_2.2]}} {{body.[input_2.3]}} {{body.[input_2.6]}}</p>
<p>{{body.input_6}}</p>
正确的模板:
提交表格
{{body.[input_2.2]}{{body.[input_2.3]}{{body.[input_2.6]}
{{body.input_6}}
这是通过反复试验发现的。。。找不到合适的文档来解释这一点不知道手杆,我猜是{{ICON[32]}
?编辑:啊,应该是图标。[32]
。Docs:已经尝试过了,但没有用yeet.使用图标。[32]
,成功了。Uriel是对的,不幸的是,他们删除了他们的答案:-/大家从这里学到了什么?始终阅读。它说需要'ID',得到'INVALID'
图标。[32]
应该是图标[32]
Proper template:
<p>Form submission</p>
<p>{{body.[input_2.2]}} {{body.[input_2.3]}} {{body.[input_2.6]}}</p>
<p>{{body.input_6}}</p>