Flask接口签名sign原理与实例代码浅析
388
2023-03-11
Vue实现web分页组件详解
本文实例为大家分享了vue实现web分页组件的具体代码,供大家参考,具体内容如下
效果演示
源代码
body{padding:0; margin: 0; broder:none; } #app {width: 500px; height: 200px; margin: 0 auto; text-align: center; background-color: #cccccc; } #mylink {color: #efefef; } .pagination{list-style: none; text-align: cexwoqQGXKWnter; height: 50px; padding-top: 50px; } .pagination > li {float: left; margin: 0 5px; } [v-cloak] {display: none; }
共:{{totalPageCount||0}}页,当前页为第{{currentPage||0}}页 设置总页数:
var app = new Vue({
el: '#app',
data: {
// 省略的符号
sign:'...',
// 省略号位置
signIndex:4,
// 总页数
totalPageCount: 4,
// 当前页
currentPage:1,
// 显示在页面的数组列表
pagingList:[]
},
watch: {
totalPageCount (val) {
var that = this
if (!val || val == '') return;
that.currentPage = 1;
that.init()
},
currentPage (val) {
var that = thhttp://is
that.init()
}
},
methods: {
// 跳转到某页码
next (num) {
var that = this
if (num <= 1) that.currentPage = 1;
else if (num >= that.totalPageCount) that.currentPage = that.totalPageCount;
else that.currentPage = num;
},
// 初始化数据
fetchData () {
var that = this
that.pagingList = [];
var tmp = null;
if ((that.totalPageCount) > 6) {
if (((that.totalPageCount-1) == (that.totalPageCount - that.currentPage)) && (that.totalPageCount - that.currentPage) > 5) {
for (var i=1;i<7;i++) {
if (i < that.signIndex) {
tmp = {key:i, value:i }
} else if (i== that.signIndex) {
tmp = {key:that.sign, value:0 }
} else if (i == (that.signIndex + 1) ) {
tmp = {key:that.totalPageCount - 1, value:that.totalPageCount - 1 }
} else {
tmp = {key:that.totalPageCount, value:that.totalPageCount }
}
that.pagingList.push(tmp)
}
} else if (((that.totalPageCount - that.currentPage) <= that.signIndex)){
var starNum = that.totalPageCount - 5;
for (var i=starNum;i tmp = {key:i, value:i } that.pagingList.push(tmp) } } else { var starNum = that.currentPage - 1; for (var i=1;i<7;i++) { if (i < that.signIndex) { tmp = {key:(starNum - 1) + i, value:(starNum - 1) + i } } else if (i== that.signIndex) { tmp = {key:that.sign, value:0 } } else if (i == (that.signIndex + 1) ) { tmp = {key:that.totalPageCount - 1, value:that.totalPageCount - 1 } } else { tmp = {key:that.totalPageCount, value:that.totalPageCount } } that.pagingList.push(tmp) } } } else { for (var i =0; i tmp = {key:i+1, value:i+1 } that.pagingList.push(tmp) } } }, init () { var that = this that.fetchData() } }, mounted () { var that = this that.init() } })
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~