告诉我,我做错了什么。在输出我得到 3 个空行
我对我在做什么的建议从这些数据中得出错误的结论
这是一个代码示例
main.js
var observable = require("data/observable");
var virtualArrayModule = require("data/virtual-array");
var http = require("http");
var mainViewModel = new observable.Observable();
var array = new virtualArrayModule.VirtualArray(3);
mainViewModel.tapAction = function () {
array.on(virtualArrayModule.knownEvents.itemsLoading, function (args) {
http.getJSON("http://www.reddit.com/r/news.json?limit=" + args.count).then(function (r) {
var itemsToLoad = r.data.children.map(function (i) {
return i.data.title;
});
array.load(args.index, itemsToLoad);
}, function (e) {
done(e);
});
});
mainViewModel.set("redditItems", array);
};
exports.mainViewModel = mainViewModel;
和 main.xml
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<StackLayout>
<Button text="Загрузить" tap="{{ tapAction }}" />
<ListView items="{{ redditItems }}">
<ListView.itemTemplate>
<GridLayout columns="auto, *, auto" rows="auto, 25">
<Label text="{{ title }}" textWrap="true" col="1" colSpan="2" minHeight="50" />
</GridLayout>
</ListView.itemTemplate>
</ListView>
<Label text="{{ error }}" cssClass="message"/>
</StackLayout>
</Page>