vue-infinite-loading: _this.$refs.infiniteLoading.$emit is not a function
code:
loadMore: function () { console.log("loadMore") getChartDetail({id: this.charts[this.activeIndex]['id'],offset:this.chartsArray[this.activeIndex].length}).then(e=>{ this.chartsArray[this.activeIndex].push(...e.books) this.$refs.infiniteLoading&&this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded'); }).catch(e => { console.log(e) }) }
first time it will work,but when i continue to scroll ,next time will produce error ‘_this.$refs.infiniteLoading.$emit is not a function’
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (9 by maintainers)
Commits related to this issue
- Add the $state special argument for the callback to change component states #57 — committed to PeachScript/vue-infinite-loading by PeachScript 7 years ago
@bruddah you can use the
this.$refs.infiniteLoading.stateChanger.loaded()method to do that.Hi everyone, v2.2.0 has been released, include this change, you can try it now, please feedback to here if you find any problem, thanks 😄
Hi everyone @tengqingya @emkman @feinimoshu753 @jkiimm @zzmm1 @xuyukuan , I think this problem cannot be fixed if this component still use
$refsto send event, because it cannot ensure the ref element always be accessible. For example if this component already was destroyed after the async request complete in theon-infinitefunction, but the callback function still try to emit event through the$refs.infiniteLoading, this error will be thrown.So I plan to change the way to send the
loadedandcompleteevent, it may looks like this:What do you think? And how about the variable name
state?Best regards.
未加载完成就停止,就会出现该错误。
@zzmm1 ,感谢,但我还没找到比较好的解决办法,也许应该换一种使用方式
持续关注中…
@zzmm1 暂时还没定位到真正的原因,只是有一些推测,有待验证。不知道你是否可以在 JSFiddle 上重现你遇到的问题?