Skip to content

Commit

Permalink
fix:修复分页
Browse files Browse the repository at this point in the history
  • Loading branch information
lfb committed Dec 26, 2021
1 parent e8eb4d0 commit c70f388
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 1 addition & 3 deletions app/dao/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class ArticleDao {
}
try {
const article = await Article.scope('iv').findAndCountAll({
// limit: page_size, //每页10条
limit: page_size, //每页10条
offset: (page - 1) * page_size,
where: filter,
order: [
Expand All @@ -170,8 +170,6 @@ class ArticleDao {
rows = dataAndAdmin
}

console.log(rows)
console.log(Array.isArray(rows) && rows.length > 0)
if (Array.isArray(rows) && rows.length > 0) {
rows.sort((a, b) => b.sort_order - a.sort_order)
}
Expand Down
2 changes: 1 addition & 1 deletion app/dao/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class CategoryDao {
try {
const category = await Category.scope('bh').findAndCountAll({
where: params,
// limit: page_size, //每页10条
limit: page_size, //每页10条
offset: (page - 1) * page_size,
order: [
['created_at', 'DESC']
Expand Down
7 changes: 3 additions & 4 deletions frontend-boblog/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<a v-if="isClear" href="/">清空搜索条件</a>
</div>

<div v-if="isLoad" class="more" @click="loadMore">
<div v-if="isLoad" class="response-wrap more" @click="loadMore">
<div class="more-text">点击加载更多</div>
<div class="more-arrow">
<img src="https://cdn.boblog.com/arrow.png" alt="" />
Expand Down Expand Up @@ -126,7 +126,7 @@ export default {
})
if (!err) {
this.categoryId = id
this.article.push(...res.data.data)
this.article.data.push(...res.data.data.data)
this.isLoad = res.data.data.meta.total_pages > this.page
}
},
Expand Down Expand Up @@ -204,8 +204,7 @@ export default {
.more {
cursor: pointer;
width: 1280px;
margin: 0 auto;
padding: 32px 0;
display: flex;
align-items: center;
justify-content: center;
Expand Down

0 comments on commit c70f388

Please sign in to comment.