我正在使用Knockout.js的currentFolder绑定语法。 我有代码:
alert(self.currentFolder().folderName + self.currentFolder());
现在,对于self.currentFolder()警报:
{
"folderSize": "105.73MB",
"folderName": "root",
"subFolders": [
{
"folderSize": "0Byte",
"folderName": "Reacl child of Root",
"subFolders": [],
"filesInFolder": []
}
],
"filesInFolder": [
{
"fileType": "mp4",
"checkSum": "4e3e31d46b4ad120af47c0836340df4d",
"fileSize": "105.73MB",
"fileName": "fileName.mp4",
"date": "14-11-2013 16:52:53",
"resourceLink": "eyJpdiI6IllaSWI5SGxTajg0dVBGUVdiNERGN3JJbllWS29UZStxclhcL1JwUDNjbkJZPSIsInZhbHVlIjoiNitNSitcL1wvVVNpT2ExdUJRWG9xazZPTFduNm90bW5BUTE2OUFnOGZ1cDBBMmJMazNcL1wvSEREM3hOczR2anNHOGNNZDFvUUc3RkxQWlhHdDVcLzJkQlVcL3c9PSIsIm1hYyI6ImUzYzIwMTM0NWFhNzBkZDY2ZjhkMmNkYjcyZThlZDJmZDIxYzYzZTBjYmI5MjQxYjgzOWY0ZmUxNDM4MWQ2YjAifQ=="
}
]
}
但我不知道为什么self.currentFolder()。folderName输出undefined。有什么建议吗?
答案 0 :(得分:0)
如果folderName
是一个可观察的,那么您需要将其称为函数,就像使用任何其他可观察类型一样。这应该适合你。
self.currentFolder().folderName()