mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 18:14:13 +00:00
[new feature] Pagination code review (#328)
* fix: Tabbar icon line-height * [new feature] progress add showPivot prop * [new feature] TabItem support vue-router * [new feature] update document header style * [Doc] add toast english ducoment * [bugfix] Search box-sizing wrong * [Doc] update vant-demo respo * [Doc] translate theme & demo pages * [Doc] add Internationalization document * [bugfix] remove unnecessary props * [fix] optimize clickoutside * [new feature] optimize find-parent * [new feature]: change document title accordinng to language * [new feature] Pagination code review
This commit is contained in:
@@ -1,104 +1,69 @@
|
||||
|
||||
## Pagination
|
||||
|
||||
### Usage
|
||||
### Install
|
||||
``` javascript
|
||||
import { Pagination } from 'vant';
|
||||
|
||||
Vue.component(Pagination.name, Pagination);
|
||||
```
|
||||
|
||||
### Demo
|
||||
### Usage
|
||||
|
||||
#### Basic Usage
|
||||
|
||||
```html
|
||||
<van-pagination
|
||||
:totalItems="totalItems"
|
||||
:itemsPerPage="itemsPerPage"
|
||||
:showPageSize="showPageSize2"
|
||||
previousText= "Prev"
|
||||
nextText= "Next"
|
||||
v-model="pagination1"
|
||||
@change="pageChanged"
|
||||
></van-pagination>
|
||||
|
||||
<pre>Page: {{pagination1.currentPage}} / {{pagination1.numPages}}</pre>
|
||||
v-model="currentPage"
|
||||
:totalItems="24"
|
||||
:itemsPerPage="5"
|
||||
/>
|
||||
```
|
||||
|
||||
```javascript
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
totalItems: 24,
|
||||
pagination1: {
|
||||
currentPage: 2
|
||||
},
|
||||
pagination2: {
|
||||
currentPage: 1
|
||||
},
|
||||
pagination3: {
|
||||
currentPage: 1
|
||||
},
|
||||
setPage (pageNo) {
|
||||
this.pagination1.currentPage = pageNo;
|
||||
},
|
||||
pageChanged () {
|
||||
console.log('Page changed to: ' + this.pagination1.currentPage);
|
||||
},
|
||||
showPageSize: 3,
|
||||
showPageSize2: 5
|
||||
bigTotalItems: 125,
|
||||
itemsPerPage: 5
|
||||
currentPage: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Set `mode=simple` use Simple Mode
|
||||
#### Simple mode
|
||||
|
||||
```html
|
||||
<van-pagination
|
||||
:totalItems="bigTotalItems"
|
||||
v-model="pagination2"
|
||||
:previousText="'Prev'"
|
||||
:nextText="'Next'"
|
||||
v-model="currentPage"
|
||||
:pageCount="12"
|
||||
mode="simple"
|
||||
></van-pagination>
|
||||
<pre>Page: {{pagination2.currentPage}} / {{pagination2.numPages}}</pre>
|
||||
/>
|
||||
```
|
||||
|
||||
#### Advanced Usage
|
||||
|
||||
Set `forceEllipses: true`, show ellipses
|
||||
#### Show ellipses
|
||||
|
||||
```html
|
||||
<van-pagination
|
||||
:totalItems="bigTotalItems"
|
||||
v-model="pagination3"
|
||||
:showPageSize="showPageSize"
|
||||
v-model="currentPage"
|
||||
:totalItems="125"
|
||||
:showPageSize="3"
|
||||
:forceEllipses="true"
|
||||
previousText= "Prev"
|
||||
nextText= "Next"
|
||||
></van-pagination>
|
||||
|
||||
<pre>Page: {{pagination3.currentPage}} / {{pagination3.numPages}}</pre>
|
||||
/>
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
| Attribute | Description | Type | Default | Accepted Values |
|
||||
|-----------|-----------|-----------|-------------|-------------|
|
||||
| v-model | pageModel | Object | - | - |
|
||||
| mode | mode | String | multi | multi : simple |
|
||||
| itemsPerPage | itemsPerPage | Number | 10 | - |
|
||||
| previousText | previousText | String | Previous | - |
|
||||
| nextText | nextText | String | Next | - |
|
||||
| showPageSize | showPageSize | Number | 5 | - |
|
||||
| forceEllipses | ellipses | Boolean | false | - |
|
||||
| v-model | pageModel | `Object` | - | - |
|
||||
| mode | mode | `String` | `multi` | `simple` |
|
||||
| itemsPerPage | itemsPerPage | `Number` | `10` | - |
|
||||
| prevText | previousText | `String` | `Previous` | - |
|
||||
| nextText | nextText | `String` | `Next` | - |
|
||||
| showPageSize | showPageSize | `Number` | `5` | - |
|
||||
| forceEllipses | ellipses | `Boolean` | `false` | - |
|
||||
|
||||
### Event
|
||||
|
||||
| Event | Description | Attribute |
|
||||
|-----------|-----------|-----------|
|
||||
| change | triggered on page change | - |
|
||||
| change | Triggered on page change | - |
|
||||
|
Reference in New Issue
Block a user