fix: window scroll

This commit is contained in:
reco_luan 2019-09-30 00:49:18 +08:00
parent 52d16e1708
commit 5294cb6516
3 changed files with 25 additions and 6 deletions

View File

@ -55,7 +55,7 @@ export default {
posts.sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})
this.getCurrentPage(1)
this._setPage(1)
return posts
},
//
@ -75,6 +75,12 @@ export default {
},
//
getCurrentPage (page) {
this._setPage(page)
setTimeout(() => {
window.scrollTo(0, 0)
}, 100)
},
_setPage (page) {
this.currentPage = page
this.$page.currentPage = page
},

View File

@ -7,7 +7,7 @@
:key="index"
:class="{'active': item.name == currentTag}"
:style="{ 'backgroundColor': item.color }"
@click="getPagesByTags(item.name)">{{item.name}}</span>
@click="tagClick(item.name)">{{item.name}}</span>
</div>
<note-abstract
class="list"
@ -79,6 +79,15 @@ export default {
methods: {
initData (currentTag) {
this.getPagesByTags(currentTag)
},
async tagClick (currentTag) {
await this.getPagesByTags(currentTag)
window.scrollTo(0, 0)
},
//
getPagesByTags (currentTag) {
this.currentTag = currentTag
@ -96,7 +105,7 @@ export default {
// reverse()
this.posts = posts.length == 0 ? [] : posts
this.getCurrentPage(1)
this._setPage(1)
},
getCurrentTag (tag) {
@ -104,11 +113,15 @@ export default {
},
getCurrentPage (page) {
this._setPage(page)
setTimeout(() => {
window.scrollTo(0, 0)
}, 100)
},
_setPage (page) {
this.currentPage = page
this.$page.currentPage = page
window.scrollTo(0, 0)
},
//
_getTimeNum (date) {
return parseInt(new Date(date.frontmatter.date).getTime())

View File

@ -1,6 +1,6 @@
{
"name": "vuepress-theme-reco",
"version": "1.0.9-alpha.3",
"version": "1.0.9-alpha.6",
"description": "this is a vuepress theme",
"main": "index.js",
"scripts": {