好吧,这可能是一个愚蠢的问题,因为我遗漏了一些东西,但我似乎无法弄清楚是什么!
这是我的对象,使用 {{ definitionList | json }}
{
"State": "Success",
"Data": [
{
"Description": "Default",
"ID": 4,
},
{
"Description": "Hello World",
"ID": 14,
},
{
"Description": "Test Def",
"ID": 11,
},
{
"Description": "test definitie",
"ID": 12,
},
{
"Description": "testffvfvfvffv",
"ID": 8,
},
{
"Description": "Werknemer_kantoor",
"ID": 3,
"Type":
},
{
"Description": "Werknemer_kantoor",
"ID": 6,
}
],
"Error": null
}
好的,现在我想打印出“数据” uisng {{ definitionList.Data | json }}
然后我收到错误
ORIGINAL EXCEPTION: Cannot read property 'Data' of undefined
我不明白为什么?我错过了什么?
最佳答案
也许您正在异步加载 definitionList
并且在执行模板时它尚未定义?
尝试使用以下代码(注意 ?
):
{{ definitionList?.Data | json }}
关于JavaScript - 无法读取未定义的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42278104/