Commit e95a2b15 authored by Regis's avatar Regis

remove use of spread operator - attempt render function

parent b0e6d078
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
data() { data() {
return { return {
nslice: +this.pagenum, nslice: +this.pagenum,
endcount: this.last,
}; };
}, },
methods: { methods: {
...@@ -20,12 +21,15 @@ ...@@ -20,12 +21,15 @@
}, },
prevstatus() { prevstatus() {
if (+this.pagenum > 1) return ''; if (+this.pagenum > 1) return '';
return 'prev disabled'; return 'disabled';
},
createSection(n) {
return Array.from(Array(n)).map((e, i) => i);
}, },
}, },
computed: { computed: {
dynamicpage() { dynamicpage() {
const section = [...Array(this.upcount).keys()]; const section = this.createSection(this.upcount);
section.shift(); section.shift();
this.nslice = +this.pagenum; this.nslice = +this.pagenum;
this.endcount = +this.pagenum + 5; this.endcount = +this.pagenum + 5;
...@@ -38,7 +42,7 @@ ...@@ -38,7 +42,7 @@
}, },
paginationsection() { paginationsection() {
if (this.last < 6 && this.pagenum < 6) { if (this.last < 6 && this.pagenum < 6) {
const pageArray = [...Array(6).keys()]; const pageArray = this.createSection(6);
pageArray.shift(); pageArray.shift();
return pageArray.slice(0, this.upcount); return pageArray.slice(0, this.upcount);
} }
...@@ -81,7 +85,7 @@ ...@@ -81,7 +85,7 @@
class="next" class="next"
v-if='(n === upcount || n === endcount) && pagenum !== last' v-if='(n === upcount || n === endcount) && pagenum !== last'
> >
<span @click='changepage($event,{where: +pagenum+1})'>Next</span> <span @click='changepage($event,{where: +pagenum + 1})'>Next</span>
</li> </li>
<li <li
class="last" class="last"
...@@ -92,5 +96,29 @@ ...@@ -92,5 +96,29 @@
</ul> </ul>
</div> </div>
`, `,
// render(createElement) {
// return createElement('div', {
// class: {
// 'gl-pagination': true,
// },
// }, [createElement('ul', {
// class: {
// pagination: true,
// clearfix: true,
// },
// }, this.paginationsection.map((e, i) => {
// if (!i) return createElement('li', [createElement('span', {
// class: {
// prev: this.prevstatus,
// },
// }, 'Prev')]);
// if (i) {
// return createElement('li',
// [createElement('span', i)]
// );
// }
// })),
// ]);
// },
}); });
})(window.gl || (window.gl = {})); })(window.gl || (window.gl = {}));
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
if (page.where) this.pagenum = +page.where; if (page.where) this.pagenum = +page.where;
if (page.where) this.pagenum = +page.where; if (page.where) this.pagenum = +page.where;
// use p instead of page to avoid making an actual request
window.history.pushState({}, null, `?p=${this.pagenum}`); window.history.pushState({}, null, `?p=${this.pagenum}`);
clearInterval(this.intervalId); clearInterval(this.intervalId);
this.store.fetchDataLoop.call(this, Vue, this.pagenum); this.store.fetchDataLoop.call(this, Vue, this.pagenum);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment