首页 文章

在fb-util无限滚动中使用$ key的问题

提问于
浏览
1

我使用fb-util进行无限滚动,一切看起来都不错 . 但是,一旦我点击了250个元素,我就会看到以下错误 . 知道这是什么意思吗?

错误:查询:按键排序时,您只能将一个参数传递给startAt(),endAt()或equalTo() . 在XhNd(https://www.gstatic.com/firebasejs/3.2.1/firebase.js) :441:298)r._listen(https:// <> /content/script/firebase-util.min.js:10:8979)r._listen(https:// <> / content / script / firebase -util.min.js:10:10961)在r.moveTo(https:// <>的r.goTo(https:// <> /content/script/firebase-util.min.js:10:8062) /content/script/firebase-util.min.js:10:3672)在r.next(https:// <> /content/script/firebase-util.min.js:10:17083)https:// aax.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)at 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,停止产生错误 . 但是,这导致了早期的元素被替换 .

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.
    

相关问题