2
2
<div class =" pagination" >
3
3
<span
4
4
class =" card-box prev iconfont icon-jiantou-zuo"
5
- :class =" {disabled: currentPage === 1}"
5
+ :class =" { disabled: currentPage === 1 }"
6
6
@click =" goPrex()"
7
7
>
8
8
<p >上一页</p >
9
9
</span >
10
10
11
11
<!-- 分页在5页及以下时 -->
12
- <div
13
- class =" pagination-list"
14
- v-if =" pages <= 5"
15
- >
12
+ <div class =" pagination-list" v-if =" pages <= 5" >
16
13
<span
17
14
class =" card-box"
18
15
v-for =" item in pages"
19
16
:key =" item"
20
- :class =" {active: currentPage === item}"
17
+ :class =" { active: currentPage === item }"
21
18
@click =" goIndex(item)"
22
- >{{item}}</span >
19
+ >{{ item }}</span
20
+ >
23
21
</div >
24
22
<!-- 分页在5页以上 -->
25
- <div
26
- class =" pagination-list"
27
- v-else
28
- >
23
+ <div class =" pagination-list" v-else >
29
24
<!-- 一号位 -->
30
25
<span
31
26
class =" card-box"
32
- :class =" {active: currentPage === 1}"
27
+ :class =" { active: currentPage === 1 }"
33
28
@click =" goIndex(1)"
34
- >1</span >
29
+ >1</span
30
+ >
35
31
36
32
<!-- 二号位 -->
37
33
<span
44
40
<span
45
41
class =" card-box"
46
42
v-show =" currentPage <= 3"
47
- :class =" {active: currentPage === 2}"
43
+ :class =" { active: currentPage === 2 }"
48
44
@click =" goIndex(2)"
49
- >2</span >
45
+ >2</span
46
+ >
50
47
51
48
<!-- 三号位 -->
52
49
<span
53
50
class =" card-box"
54
- :class =" {active: currentPage >= 3 && currentPage <= ( pages - 2) }"
51
+ :class =" { active: currentPage >= 3 && currentPage <= pages - 2 }"
55
52
@click =" goIndex(threeNum())"
56
- >{{ threeNum() }}</span >
53
+ >{{ threeNum() }}</span
54
+ >
57
55
58
56
<!-- 四号位 -->
59
57
<span
60
58
class =" ellipsis ell-four"
61
- v-show =" currentPage < ( pages - 2) "
59
+ v-show =" currentPage < pages - 2"
62
60
@click =" goIndex(currentPage + 2)"
63
61
title =" 下两页"
64
62
/>
65
63
<span
66
64
class =" card-box"
67
- v-show =" currentPage >= (pages - 2)"
68
- :class =" {active: currentPage === pages-1}"
69
- @click =" goIndex(pages-1)"
70
- >{{ pages-1 }}</span >
65
+ v-show =" currentPage >= pages - 2"
66
+ :class =" { active: currentPage === pages - 1 }"
67
+ @click =" goIndex(pages - 1)"
68
+ >{{ pages - 1 }}</span
69
+ >
71
70
72
71
<!-- 五号位 -->
73
72
<span
74
73
class =" card-box"
75
- :class =" {active: currentPage === pages}"
74
+ :class =" { active: currentPage === pages }"
76
75
@click =" goIndex(pages)"
77
- >{{pages}}</span >
76
+ >{{ pages }}</span
77
+ >
78
78
</div >
79
79
80
80
<span
81
81
class =" card-box next iconfont icon-jiantou-you"
82
- :class =" {disabled: currentPage === pages}"
82
+ :class =" { disabled: currentPage === pages }"
83
83
@click =" goNext()"
84
84
>
85
85
<p >下一页</p >
@@ -104,12 +104,12 @@ export default {
104
104
}
105
105
},
106
106
computed: {
107
- pages () { // 总页数
107
+ pages () { // 总页数
108
108
return Math .ceil (this .total / this .perPage )
109
109
}
110
110
},
111
111
methods: {
112
- threeNum () { // 三号位页码计算
112
+ threeNum () { // 三号位页码计算
113
113
let num = 3
114
114
const currentPage = this .currentPage
115
115
const pages = this .pages
@@ -122,24 +122,24 @@ export default {
122
122
}
123
123
return num
124
124
},
125
- goPrex () {
125
+ goPrex () {
126
126
let currentPage = this .currentPage
127
127
if (currentPage > 1 ) {
128
128
this .handleEmit (-- currentPage)
129
129
}
130
130
},
131
- goNext () {
131
+ goNext () {
132
132
let currentPage = this .currentPage
133
133
if (currentPage < this .pages ) {
134
134
this .handleEmit (++ currentPage)
135
135
}
136
136
},
137
- goIndex (i ) {
137
+ goIndex (i ) {
138
138
if (i !== this .currentPage ) {
139
139
this .handleEmit (i)
140
140
}
141
141
},
142
- handleEmit (i ) {
142
+ handleEmit (i ) {
143
143
this .$emit (' getCurrentPage' , i)
144
144
}
145
145
}
@@ -151,6 +151,9 @@ export default {
151
151
position relative
152
152
height 60px
153
153
text-align center
154
+ @media (max-width 720px )
155
+ margin-left 1px
156
+ margin-right 1px
154
157
span
155
158
line-height 1rem
156
159
opacity 0.9
@@ -176,16 +179,20 @@ export default {
176
179
top 0
177
180
padding 1rem 1.2rem
178
181
font-size 0.95rem
182
+ & ::before
183
+ font-size 0.4rem
179
184
& .disabled
180
185
color rgba (125 , 125 , 125 , 0.5 )
181
186
& .prev
182
187
left 0
183
- border-top-right-radius 32px
184
- border-bottom-right-radius 32px
188
+ // border-top-right-radius 32px
189
+ // border-bottom-right-radius 32px
190
+ & ::before
191
+ margin-right 0.3rem
185
192
& .next
186
193
right 0
187
- border-top-left-radius 32px
188
- border-bottom-left-radius 32px
194
+ // border-top-left-radius 32px
195
+ // border-bottom-left-radius 32px
189
196
& ::before
190
197
float right
191
198
margin-left 0.3rem
0 commit comments