1

無限スクロールに fb-util を使用していますが、すべて問題ないようです。ただし、250 要素に達すると、次のエラーが表示されます。これは何についてですか?

エラー: クエリ: キーで並べ替える場合、startAt()、endAt()、または equalTo() に引数を 1 つだけ渡すことができます。Jh ( https://www.gstatic.com/firebasejs/3.2.1/firebase.js:431:117 ) で XgNd ( https://www.gstatic.com/firebasejs/3.2.1/firebase.js: 441:298 ) r._grow (https://<>/content/script/firebase-util.min.js:10:8979) で r._listen (https://<>/content/script/firebase- r.goTo (https://<>/content/script/firebase-util.min.js:10:8062) で r.moveTo (https://<>/ https://ajaxの r.next (https://<>/content/script/firebase-util.min.js:10:17083) の content/script/firebase-util.min.js:10:3672) .googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:198:424 at xa.(無名関数) (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:59:133 ) l.$eval ( https://ajax.googleapis.com/ajax/libs/ angularjs/1.3.8/angular.min.js:126:84 )

コード:

var baseRef = firebase.database().ref().child(refPath);
var scrollRef = new firebase.util.Scroll(baseRef, '$key');
scrollRef.scroll.next(25);
var list = $firebaseArray(scrollRef);
list.scroll = scrollRef.scroll;

フロントエンド コード:

<div infinite-scroll="vm.products.scroll.next(10)" infinite-scroll-distance="1">

nb: キーを $key から $priority または name または productid に変更すると、エラーが発生しなくなりました。しかし、これにより以前の要素が置き換えられました。

4

1 に答える 1

0

したがって、質問の最初の部分に対する回答はありませんが、追加のメモに基づいて、次の修正があります。

var scrollRef = new firebase.util.Scroll(baseRef, '$priority', {maxCacheSize: 750, windowSize: 500});

maxCacheSize と windowSize をより高い値に設定すると、問題が解決するはずです。ドキュメントによると、windowSize を超えると、サイズを制限以下に保つために配列の先頭がトリミングされます。

ドキュメンテーション:

Keys/values that can be passed via opts:

{int} windowSize: the maximum number of records to have loaded in the list at any given time. 3-5 times the size of the viewable window is a good optimization, depending on how fast content is scrolled and the payload of each record (i.e. how long it takes to download).
{int} maxCacheSize: in general, leave this as the default. This controls the internal cursor's cache, which is used to find the current position in the list. This controls how many keys it can load at any given time. This is, by default, three times the size of windowSize and should always be larger than windowSize.
于 2016-12-20T16:49:02.287 に答える