我正在网格中工作(技术上是WinJS.UI.ListView),当用户触摸其中一个图 block 时,我想导航到第二页,其中包含有关该元素的更多详细信息。我可以导航到不同的页面,但无法获取所选项目的详细信息
最佳答案
所选项目通常作为导航中的参数传递。
因此,当您导航到详细信息页面时,您可能会使用:
var item = Data.items.getAt(args.detail.itemIndex);
nav.navigate("/pages/itemDetail/itemDetail.html", { item: Data.getItemReference(item) });
然后在详细信息页面中您可以访问传递给ready函数的选项参数:
ready: function (element, options) {
// The data you passed in will be in the options parameter
var item = options && options.item ? Data.resolveItemReference(options.item) : Data.items.getAt(0);
}
您可以在 MSDN 上了解有关 WinJS 导航的更多信息:http://msdn.microsoft.com/en-us/library/windows/apps/hh738344.aspx
关于javascript - 在 WinJS 导航应用程序的新页面中显示 ListView 控件中所选项目的详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13283659/