一、下载库

官方文档地址为:
https://ext.dcloud.net.cn/plugin?id=32

点击下载zip压缩包即可,下载完毕后解压到放置前端相关组件目录,即components目录。

二、使用

1.引入

import uniPagination from '../../components/uni-pagination/uni-pagination/uni-pagination.vue'

2.模板区域使用(在里)

<uni-pagination @change="handlePage" show-icon="true" :total="postCount" :current="pageNum" :pageSize="pageSize"></uni-pagination>

3.编写handlePage函数

handlePage(params){
var pageIndex = params.current; console.log("this.pageNum:"+pageIndex); this.getPostListInfo(pageIndex)
}

4.我的完整代码如下

<template>
<view class="content">
<!-- <image class="logo" src="/static/logo.png"></image> -->
<view class="text-area">
<text class="title">{{ title }}</text>
</view>
<view class="uni-list">
<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item, index) in list" :key="index">
<!-- <view class="uni-list-cell-navigate uni-navigate-right">{{ item.Title }}</view> --> <button type="default" @click="getDetail(item.Title, item.Id, item.Url)">{{ item.Title }}</button>
</view>
<uni-pagination @change="handlePage" show-icon="true" :total="postCount" :current="pageNum" :pageSize="pageSize"></uni-pagination>
</view>
</view>
</template> <script>
import common from '../../common/common.js';
import uniPagination from '../../components/uni-pagination/uni-pagination/uni-pagination.vue';
export default {
components: { uniPagination },
data() {
return {
title: '文章列表',
postCount: 0,
pageSize: 10,
pageNum: 1,
list: []
};
}, onLoad() {
this.getPostListInfo(this.pageNum); this.getPersonalBlogInfo();
},
methods: {
getPostListInfo(pageIndex) {
console.log('pageIndex:' + pageIndex);
uni.request({
url: common.website_url + '/cnblogs/getPersonalBlogPostList/' + pageIndex,
method: 'POST',
success: res => {
console.log('isSuccess');
console.log('getPostListInfo:' + JSON.stringify(res.data));
this.list = res.data;
},
fail: function(e) {
console.log('接口调用失败:' + JSON.stringify(e));
}
});
}, getPersonalBlogInfo() {
uni.request({
url: common.website_url + '/cnblogs/getPersonalBlogInfo',
method: 'POST',
success: res => {
//console.log('getPersonalBlogInfo:' + JSON.stringify(res.data));
this.postCount = res.data.postCount;
this.pageSize = res.data.pageSize;
},
fail: function(e) {
console.log('接口调用失败:' + JSON.stringify(e));
}
});
},
getDetail(Title, Id, Url) {
console.log('Title:' + Title + ' Id:' + Id); uni.navigateTo({
url: '../post/post/post?Title=' + Title + '&Id=' + Id
});
},
handlePage(params) {
var pageIndex = params.current; console.log('this.pageNum:' + pageIndex); this.getPostListInfo(pageIndex);
}
}
};
</script> <style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
} .logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
} .text-area {
display: flex;
justify-content: center;
} .title {
font-size: 36rpx;
color: #8f8f94;
}
</style>

5.效果图

界面虽然不好看,但功能是Ok的。

当前页

点击下一页

最新文章

  1. curl 模拟登录微信公众平台带验证码
  2. Shell 编程基础之 Break, Continue 练习
  3. FatMouse的交易问题
  4. redis中模糊删除
  5. txt用Itunes同步到IPhone上
  6. 即时通信Spark安装和配置
  7. golang学习之指针、内存分配
  8. IP地址计算和划分
  9. QML鼠标事件实现变色矩形
  10. (转)IOS学习笔记-2015-03-29 int、long、long long取值范围
  11. 关于EventHandler的使用
  12. Beyond Compare设置默认为ANSI格式
  13. 引用(ajaxfileupload.js) ajaxfileupload.js报这错jQuery.handleError is not a function
  14. java 请求响应乱码
  15. ArcGIS 10 破解安装(win7 64位)
  16. sugarcrm关于邮件设置几个不好理解的地方
  17. 雕爷:我眼中的O2O成长路径
  18. 在app中屏蔽第三方键盘
  19. 从Dynamics CRM2011到Dynamics CRM2016的升级之路
  20. 杭电ACM2012--素数判定

热门文章

  1. 简说Spring中的资源加载
  2. 剑指Offer之旋转数组的最小数字
  3. RabbitMq和ZeroMq
  4. &amp; vue项目中的rem适配
  5. centos6.4中文输入法
  6. Flutter 动画鼻祖之CustomPaint
  7. js匿名函数和date对象,math对象
  8. Java并发编程 (四) 线程安全性
  9. 数据库之 MySQL --- 数据处理 之多表查询 (三)
  10. Java实现 LeetCode 754 到达终点数字(暴力+反向)