Skip to content

Commit

Permalink
-> 1.02
Browse files Browse the repository at this point in the history
  • Loading branch information
sinchang committed Apr 3, 2017
1 parent 633fa4e commit 09b0161
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 37 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $ npm install vue-laypage --save
```

```
import Laypage from 'vue-laypage';
import Laypage from 'vue-laypage'
export default {
components: {
Laypage
Expand All @@ -20,9 +20,10 @@ export default {
or

```
import Vue from 'vue';
import Laypage from 'vue-laypage';
Vue.component('Laypage', Laypage);
import Vue from 'vue'
import Laypage from 'vue-laypage'
Vue.use(Laypage)
```
## Props
| Name | Type | Description |
Expand Down
7 changes: 1 addition & 6 deletions demo/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
</template>

<script>
import Laypage from '../src/Laypage';
export default {
name: 'app',
data() {
Expand All @@ -27,12 +25,9 @@
next: false
}
},
components: {
Laypage
},
methods: {
cb(page) {
this.page = page;
this.page = page
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions demo/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Vue from 'vue';
import App from './App';
import Vue from 'vue'
import App from './App'
import Laypage from '../src/index'

Vue.use(Laypage)

new Vue({
el: '#app',
Expand Down
1 change: 1 addition & 0 deletions hot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hot reloading enabled
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-laypage",
"version": "1.0.1",
"version": "1.0.2",
"description": "A simple pagination component for Vue.js",
"main": "dist/vueLaypage.js",
"scripts": {
Expand All @@ -24,8 +24,9 @@
"author": "sinchang <sinchangwen@gmail.com>",
"license": "MIT",
"devDependencies": {
"laravel-mix": "^0.7.2",
"vue": "^2.1.10"
"laravel-mix": "^0.7.2"
},
"dependencies": {}
"dependencies": {
"vue": "^2.1.10"
}
}
43 changes: 24 additions & 19 deletions src/Laypage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,47 +62,52 @@
},
computed: {
pagesNumber() {
let from, to;
let diff = (this.groups - 1) / 2;
let from, to
let diff = (this.groups - 1) / 2
if (this.groups > this.pages) {
throw new Error('groups can not greater than pages')
}
if (this.diff % 2 === 0) {
from = this.cur - diff;
to = this.cur + diff;
from = this.cur - diff
to = this.cur + diff
} else {
from = this.cur - Math.floor(diff);
to = this.cur + Math.ceil(diff);
from = this.cur - Math.floor(diff)
to = this.cur + Math.ceil(diff)
}
if (from < 1) {
from = 1;
to = this.groups;
from = 1
to = this.groups
}
if (to >= this.pages) {
to = this.pages;
from = to - this.groups + 1;
to = this.pages
from = to - this.groups + 1
}
let pagesArr = [];
let pagesArr = []
while (from <= to) {
pagesArr.push(from);
from++;
pagesArr.push(from)
from++
}
return pagesArr;
return pagesArr
}
},
methods: {
changePage(page) {
this.cur = page;
this.jump(page);
this.cur = page
this.jump(page)
},
jumpFunc() {
if (!this.jumpPage) {
return;
return
}
this.changePage(parseInt(this.jumpPage));
this.jumpPage = '';
this.changePage(parseInt(this.jumpPage))
this.jumpPage = ''
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import Laypage from './Laypage.vue';
import Laypage from './Laypage.vue'

export default Laypage;
Laypage.install = Vue => {
Vue.component(Laypage.name, Laypage)
}

if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(Laypage)
}

export default Laypage

0 comments on commit 09b0161

Please sign in to comment.