When I log, it shows:
"names": {
"en": "X"
},
"images": [
"https://x.com/1.jpg"
]
and the Template is:
<div>{{images.[1]}}</div>
<div>{{names.en}}</div>
But images' div
is empty.
How to fix this?
Try:
<div>{{images.[0]}}</div>
Handlebars syntax is weird, if you are accessing an element in an array, do this:
{{images.[0]}}
This doesn't work:
{{images[0]}}
{{images.0}}
But, if the element has a nested property you can do this:
{{images.0.otherProp}}
<div>{{images[0]}}</div>
<div>{{names.en}}</div>
images
is an array and array index starts from 0.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.