我基本上想显示嵌套在tvSeason中的情节,该情节也嵌套在seriesMovie

<% seriesMovie.tvSeasons.forEach(function(tvSeason) { %>
    <h1>
    <%= tvSeason["episodes"].episode_number %>
    </h1>
<% }) %>


"tvSeasons" : [
    {
        "season_id" : "4321",
        "episode_count" : "22",
        "season_number" : "1",
        "overview" : "nothing",
        "image_path" : "grey.jpg",
        "release_date" : "2005-12-24",
        "episodes" : [
            {
                "episode_id" : "4553",
                "episode_number" : "1",
                "episode_title" : "rage",
                "image_path" : "rey.jpg",
                "video_path" : "rom.mp4",
                "episode_runtime" : "42"
            }
        ]
]


未定义Episode_number

最佳答案

为什么不起作用?

似乎情节是一个数组...因此,如果要访问第一个情节,只需指出episode[0] ...

<% seriesMovie.tvSeasons.forEach(function(tvSeason) { %>
    <h1>
    <%= tvSeason["episodes"][0].episode_number %>
    </h1>
<% }) %>

09-20 20:53