【发布时间】:2017-01-07 17:15:57
【问题描述】:
我在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'
我该如何解决这个问题?
【问题讨论】:
-
不知道手把,我猜
{{ ICON[32] }}? edit: 啊,应该是ICON.[32]。文档:handlebarsjs.com/expressions.html -
已经试过了,没用。
-
用
ICON.[32],它成功了。 -
Uriel 是对的,不幸的是他们删除了他们的答案:-/
-
大家在这里学到了什么?始终阅读documentation。