Comments (2)
我已经有了解决方案, 请参考:
// 滚动加载事件
pullUp() {
console.log('getComment')
getComment(this.$route.params.id, this.page).then(({ comments }) => {
// 因为重复的部分是有规律的, 即已经获取的所有评论commentList最后的部分可能会和新请求的comments前面几个重复.
//所以只要遍历可能重复的部分, 直到不再遇到重复就可以停止遍历
let commentsLen = comments.length
for (let i = 0; i < commentsLen; i++) {
let originSearch = this.commentList.length - 1 - i
if (comments[i].commentId === this.commentList[originSearch].commentId) {
const duplicate = comments.shift()
console.log('重复: ')
console.log(duplicate)
i--
commentsLen--
} else {
break
}
}
this.commentList = [...this.commentList, ...comments]
console.log('@@@ 合并后: ')
// 如果this.commentList.length不是30的倍数,则说明有重复的
console.log(this.commentList.length)
console.log(comments.length)
console.log(this.commentList)
console.log(comments)
})
}
from vue-mmplayer.
好像可以先标记出重复, 然后截取comments. 我对js语法不太熟悉. 作者你可以看着进行优化
from vue-mmplayer.
Related Issues (20)
- Cannot read properties of undefined (reading 'hots') at search.vue:75:1 HOT 1
- 感谢陪伴,老哥有缘再见。
- 歌词
- 感谢陪伴 HOT 5
- 可怜被捧杀
- 没有我喜欢歌单吗? HOT 1
- 感谢作者。我一直用的好好的。可惜可惜。
- 你好可以加您qq或者微信,解答我一个问题吗 HOT 1
- 部署之后打开是network error错误 HOT 1
- 缺德啊
- 能否docker版本
- 还好我看到了别人的宣传
- 可以考虑兼容alist服务端或webdav协议吗?
- Uncaught runtime errors: HOT 1
- 希望能重开一个音乐播放器,之前的整合了各大平台,很好哇,怎么就封了呢呜呜呜 HOT 2
- 套个壳壳继续上线
- Integration with piped API
- 想问问前端怎么对接api拿到歌曲的 HOT 8
- 可以播放本地音乐吗 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-mmplayer.