我有一个 populateTable 函数,并且尝试将从 JSON 文件读取的几种不同文件类型组合成一种显示类型。在本例中,将 mp4 和 m4v 转换为 MOV — 我没有收到任何错误,但表中的所有内容都未定义。
function populateTable() {
function setGenericType(type) {
if(type == 'mp4' || type == 'm4v') {
return 'MOV'
}
}
for (const d of data) {
$("#contents").append(`<tr>
<td>${d.title}</td>
<td>${d.year}</td>
<td>${setGenericType(d)}</td>
</tr>`)
}
}
有任何想法吗?data.js 中的 JSON 示例:
{
"title":"Arc Transition",
"year":2016,
"type":"mp4"
}
蓝山帝景
相关分类