Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
singleStore
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Max
singleStore
Commits
dcf3a32d
Commit
dcf3a32d
authored
Jun 07, 2021
by
June
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分页
parent
34aac71b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
utils/list-page.js
utils/list-page.js
+40
-0
No files found.
utils/list-page.js
View file @
dcf3a32d
import
{
isFunction
}
from
'
@/utils/types.js
'
import
Toast
from
'
@/lib/storage/index.js
'
/**
* 多页加载
*/
class
ListPages
{
constructor
()
{
this
.
page
=
1
// 当前页面
this
.
counts
=
10
// 每页的数量
this
.
flat
=
false
// 是否在请求
}
async
getList
(
cb
)
{
try
{
if
(
this
.
flat
||
!
isFunction
(
cb
))
return
console
.
log
(
'
正在请求中获取callback不是函数
'
)
await
cb
.
call
(
this
,
this
.
page
,
this
.
counts
)
this
.
page
++
this
.
flat
=
false
}
catch
(
error
)
{
console
.
log
(
error
)
Toast
({
title
:
'
获取列表失败
'
})
}
}
// 将页数重置为0 不重置为0也可以 看情况处理
async
refresh
(
cb
)
{
try
{
if
(
this
.
flat
||
!
isFunction
(
cb
))
return
console
.
log
(
'
正在请求中获取callback不是函数
'
)
this
.
page
=
1
await
cb
.
call
(
this
,
1
,
this
.
counts
)
this
.
page
++
this
.
flat
=
false
}
catch
(
error
)
{
console
.
log
(
error
)
Toast
({
title
:
'
获取列表失败
'
})
}
}
}
export
default
ListPages
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment