399 |
400 |
401 |
402 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vuejs-paginate-next
2 |
3 | 
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | [](https://badges.aleen42.com/src/vue.svg)
12 | [](https://badges.aleen42.com/src/javascript.svg)
13 | [](https://badges.aleen42.com/src/vitejs.svg)
14 | [](https://badges.aleen42.com/src/rollup.svg)
15 |
16 |
17 |
18 |
19 |
20 |
21 | A Vue.js (v3) component to make pagination, based on [vuejs-paginate](https://github.com/lokyoung/vuejs-paginate) from [lokyoung](https://github.com/lokyoung). Thank [bverheec](https://github.com/bverheec) for his Vue.js v3 solution in issue [#128](https://github.com/lokyoung/vuejs-paginate/issues/128).
22 |
23 | Easy to use by providing simple api. And you can customize the style of this component by CSS.
24 |
25 |
26 |
27 | ## Installation
28 |
29 | ### NPM
30 |
31 | Install the npm package.
32 |
33 | ```js
34 | $ npm install vuejs-paginate-next --save
35 | ```
36 |
37 | Register the component.
38 |
39 | ```js
40 | import Paginate from "vuejs-paginate-next";
41 | ```
42 |
43 | ---
44 |
45 | _Note_: For users using original **vuejs-paginate** package, just directly adopt **initial-page** as initial page setting instead of **value**.
46 |
47 | After Vue 3, the `Vue.use(Paginate)` is **deprecated**. You should use `app.createApp({...}).use(Paginate).mount('#app')` instead.
48 |
49 | ---
50 |
51 | ### CDN
52 |
53 | Include the source file.
54 |
55 | ```html
56 |
57 |
58 |
59 |
60 | ```
61 |
62 | ## Usage
63 |
64 | ### In Vue Template
65 |
66 | **Basic Usage**
67 |
68 | ```html
69 |
76 |
77 | ```
78 |
79 | _Note_: In vue template, camelCase and kebab-case are both supported. For example, you can either use prop `page-count` or `pageCount`. They are leading to the same result.
80 |
81 | So this is also avaliable
82 |
83 | ```html
84 |
91 |
92 | ```
93 |
94 | **Example**
95 |
96 | ```html
97 |
98 |
108 |
109 |
110 |
111 |
124 |
125 |
135 | ```
136 |
137 | ### Value Binding
138 |
139 | Use `v-model` to set the selected page number. You can programmatically modify the current page by using this.
140 |
141 | ```html
142 |
143 |
154 |
155 |
156 |
157 |
166 | ```
167 |
168 | ### In HTML
169 |
170 | Must use kebab-case for props in pure HTML.
171 |
172 | **Example**
173 |
174 | JavaScript
175 |
176 | ```js
177 | new Vue.createApp({
178 | components: {
179 | paginate: VuejsPaginateNext,
180 | },
181 | methods: {
182 | clickCallback: function (pageNum) {
183 | console.log(pageNum);
184 | },
185 | },
186 | }).mount("#app");
187 | ```
188 |
189 | HTML
190 |
191 | ```html
192 |
193 |
200 |
201 |
202 | ```
203 |
204 | ## Props
205 |
206 | | Name | Type | Description |
207 | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
208 | | `page-count` | `Number` | Total count of pages. **required** |
209 | | `page-range` | `Number` | Range of pages which displayed. **default: 3** _(Note: It is recommended to use an odd number, so that the same number of pages are displayed before and after the active page. If using an even number, there will be one more page number before the active page than after the current page)_ |
210 | | `margin-pages` | `Number` | The number of displayed pages for margins. **default: 1** |
211 | | `prev-text` | `String` | Text for the previous button. You can use HTML here. **default: Prev** |
212 | | `next-text` | `String` | Text for the next button. You can use HTML here. **default: Next** |
213 | | `break-view-text` | `String` | Text for the break view indicator. **default: ...** |
214 | | `initial-page` | `Number` | The index of initial page which selected. **default: 1** |
215 | | `force-page` | `Number` | The page number of overridden selected page. |
216 | | `click-handler` | `Function` | The method to call when page clicked. Use clicked page number as parameter. |
217 | | `container-class` | `String` | CSS class name for the layout. |
218 | | `page-class` | `String` | CSS class name for tag `li` of each page element. |
219 | | `page-link-class` | `String` | CSS class name for tag `a` of each page element. |
220 | | `prev-class` | `String` | CSS class name for tag `li` of `previous` element. |
221 | | `prev-link-class` | `String` | CSS class name for tag `a` of `previous` element. |
222 | | `next-class` | `String` | CSS class name for tag `li` of `next` element. |
223 | | `next-link-class` | `String` | CSS class name for tag `a` of `next` element. |
224 | | `break-view-class` | `String` | CSS class name for tag `li` of `break view` element. |
225 | | `break-view-link-class` | `String` | CSS class name for tag `a` of `break view` element. |
226 | | `active-class` | `String` | CSS class name for active page element. **default: active** |
227 | | `disabled-class` | `String` | CSS class name for disabled page element. **default: disabled** |
228 | | `no-li-surround` | `Boolean` | Support no `li` tag surround `a` tag. **default: false** |
229 | | `first-last-button` | `Boolean` | Support buttons to turn to the first and last page. **default: false** |
230 | | `first-button-text` | `String` | Text for first button. (Not visible when `first-last-button` is false. You can use HTML here.) **default: 'First'** |
231 | | `last-button-text` | `String` | Text for last button. (Not visible when `first-last-button` is false. You can use HTML here.) **default: 'Last'** |
232 | | `hide-prev-next` | `Boolean` | Hide prev/next button when there is no previous or next page. **default: false** |
233 |
234 | ## Customize inner HTML (experimental)
235 |
236 | You can customize the inner HTML of the previous button, next button, and break view indicator, with the `slot` tag.
237 |
238 | **Slot names**
239 |
240 | | Name | Description |
241 | | ------------------ | -------------------- |
242 | | `prevContent` | Previous button |
243 | | `nextContent` | Next button |
244 | | `breakViewContent` | Break view indicator |
245 |
246 | **Note**
247 | Slot of `prevContent` and `nextContent` are not supported after `v1.9.5`. You can directly set the HTML by `prev-text` and `next-text` props.
248 |
249 | **Example**
250 |
251 | ```html
252 |
259 | Changed previous button
260 | Changed next button
261 |
262 |
267 |
268 |
269 | ```
270 |
271 | ## Demo
272 |
273 | You can see the demo for quickly understand how to use this package.
274 |
275 | ```sh
276 | $ git clone https://github.com/cloudeep/vuejs-paginate-next.git
277 | $ cd vuejs-paginate-next
278 | $ npm install
279 | $ npm run dev
280 | ```
281 |
282 | Check the code from `./index.html` and `./src/App.vue`.
283 |
--------------------------------------------------------------------------------