1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
| <!-- -->
| <template>
| <div v-if="pagetotal>0" class="page_box">
| <div class="page_item" :style="`cursor:${pagecurrent==1?'not-allowed':'pointer'}`" @click="pagePrev"><</div>
| <div v-for="i in sum" :key="i" @click="pageItem(i)" :style="`background-color:${i==pagecurrent?'rgba(41, 182, 246, 1)':'transparent'};color:${i==pagecurrent?'#fff':'coral'}`" class="page_item">{{i}}</div>
| <div class="page_item" :style="`cursor:${pagecurrent==sum?'not-allowed':'pointer'}`" @click="pageNext">></div>
| </div>
| </template>
|
| <script>
|
| export default {
| name: "ypagination",
| components: {},
| props: {
| total: {
| type: Number,
| require: true,
| },
| current:{
| type:Number,
| default:1,
| }
| },
| data() {
| return {
| pagecurrent:this.current,
| };
| },
| created() {},
| mounted() {
| if(!this.pagetotal)this.pagetotal=0
| // console.log(this.pagetotal,34)
| },
| computed: {
| sum(){
| return Math.ceil(this.pagetotal/2)
| },
| pagetotal(){
| return this.total
| }
| },
| watch: {
| pagecurrent(val){
| this.$emit('ychange',val)
| }
| },
| methods: {
| pagePrev(){
| if(this.pagecurrent==1)return
| this.pagecurrent= this.pagecurrent - 1
| },
| pageNext(){
| if(this.pagecurrent==this.sum)return
| this.pagecurrent= this.pagecurrent + 1
| },
| pageItem(val){
| if(this.pagecurrent==val)return
| this.pagecurrent = val
| },
| },
| };
| </script>
| <style scoped>
| .page_box {
| display: flex;
| justify-content: center;
| height: 40px;
| line-height: 40px;
| }
| .page_box .page_item {
| width: 30px;
| height: 30px;
| line-height: 30px;
| text-align: center;
| font-size: 24px;
| color: coral;
| border: 1px solid rgba(3, 169, 244, 1) ;
| margin: 0 3px;
| cursor: pointer;
| }
| </style>
|
|