每次向下滚动时,我都会使用这个react-infinite-scroller库来加载更多的项目,但由于某些原因,loadmore不会为我触发。 代码如下所示: 代码语言:javascript 复制 import React from 'react'; import {Route, Link} from 'react-router-dom'; import FourthView from '../fourthview/fourthview.component'; import {Boo...
以无限滚动为例,我们可以使用IntersectionObserver API来检测列表底部的可见性,从而触发数据的加载: function InfiniteList({ data, loadMore }) { const ref = useRef(null); useEffect(() => { const observer = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { loadMore(); } }, {...
mutations: {//同步修改 只能在mutations中修改state 触发 commit //同步代码不能写异步 setCode ( state, action ) { console.log() state = action } setDataList ( state, action ) { state.data = action } }, actions: {//异步操作 触发 dispatch getDataList ({ commit }) { const data = axio...