【发布时间】:2026-01-03 02:45:02
【问题描述】:
来自 api 的示例响应:
"results":[
{
"id":16228,
"name":"ABCD",
"preview":"/d8a/d8a61a3a12e52114afdbc28f2c813f5c.jpg",
"data":{
"480":"https://mdb.net/steam/6693661/movie480.mp4",
"max":"https://mdb.net/steam/6693661/movie_max.mp4"
}
我的界面如下:
interface Movie {
data: {
max: string;
480: string;
};
}
当我尝试时
<video
class="movie"
controls
*ngFor="let trailer of results"
>
<source src="{{ trailer.data.480 }}" <-------- Error here
type="video/mp4" />
Your browser does not support the video tag.
</video>
NG5002:解析器错误:[{{ trailer.data.480 }}] 中的第 14 列出现意外令牌“0.48”
如何解决?
当问号出现时,我如何修复 {{ trail.data?['480'] }}
谢谢
【问题讨论】:
标签: angular interface response numeric angular12