期待“ID”,得到“NUMBER”

Om3*_*3ga 3 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.com/bubble-academy.jpg",
    "120":"https://example.com/bubble-academy.jpg",
    "32":"https://example.com/bubble-academy.jpg"
}
Run Code Online (Sandbox Code Playgroud)

在车把中,我试图访问32如下所示的属性。

<img src="{{ ICON.32 }}">
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

Module build failed: Error: Parse error on line 5:
..."{{ mediaFiles.ICON.32  }}">        <sp
-----------------------^
Expecting 'ID', got 'NUMBER'
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?

Tha*_*uni 5

这是因为您使用的是数字作为属性名称,请尝试使用它:

<img src="{{ ICON.[32] }}">