我有一堆json项。我正在尝试将它们附加到div。附加单个项目后,我调用一个函数来检查document.documentElement.scrollHeight的值。但是,随着列表的增加和浏览器显示滚动条,此功能无法为我提供后续调用的正确值。 我正在关注本教程https://scotch.io/tutorials/simple-asynchronous-infinite-scroll-with-vue-watchers
//this function is inside the methods: of Vuejs
function isBottomReached(){
//Use document.documentElement.scrollHeight here to return a boolean value.
}
var bigListofItems = [];//an array with lots of objects in it.
//loop over the list and show items based on the val of isBottomReached()
//this logic is inside the created() hook of Vue
if(this.isBottomReached()){
//append to DOM
}
我希望每当调用isBottomReached()函数时,它都应该在那个确切的时间点为我提供浏览器的scrollHeight。