我可以像这样获得Repeater
的项目:
var item = repeater.itemAt(index);
但是如何才能获得GridView
的项目?我看到了itemAt function。但它与itemAt
的{{1}}不同。它需要Repeater
和x
坐标,但我们可以使用y
中的索引,例如GridView
。我该如何访问该项目?
修改:
Repeater
我总是看到gridView.currentIndex = index;
var a = gridView.currentItem;
gridView.currentIndex = lastIndex;
var b = gridView.currentItem;
if (a.imageSource === b.imageSource) console.log('Equals!');
输出。但是它们(图像)不等于(a有1.png,b有2.png)。
答案 0 :(得分:1)
似乎没有功能的构建,但你可以尝试这种方法:
gridView.currentIndex = index; // your index
var item = gridView.currentItem;
// reset the current index to the previous value if you have to
也许这也会起作用(未经测试):
var item = gridView.children[index];
这更像是一种解决方法,但应该适用于你的情况。