File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed
Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ export default {
5555 posts .sort ((a , b ) => {
5656 return this ._getTimeNum (b) - this ._getTimeNum (a)
5757 })
58- this .getCurrentPage (1 )
58+ this ._setPage (1 )
5959 return posts
6060 },
6161 // 标题只显示分类名称
@@ -75,6 +75,12 @@ export default {
7575 },
7676 // 获取当前页码
7777 getCurrentPage (page ) {
78+ this ._setPage (page)
79+ setTimeout (() => {
80+ window .scrollTo (0 , 0 )
81+ }, 100 )
82+ },
83+ _setPage (page ) {
7884 this .currentPage = page
7985 this .$page .currentPage = page
8086 },
Original file line number Diff line number Diff line change 77 :key =" index"
88 :class =" {'active': item.name == currentTag}"
99 :style =" { 'backgroundColor': item.color }"
10- @click =" getPagesByTags (item.name)" >{{item.name}}</span >
10+ @click =" tagClick (item.name)" >{{item.name}}</span >
1111 </div >
1212 <note-abstract
1313 class =" list"
@@ -79,6 +79,15 @@ export default {
7979
8080 methods: {
8181
82+ initData (currentTag ) {
83+ this .getPagesByTags (currentTag)
84+ },
85+
86+ async tagClick (currentTag ) {
87+ await this .getPagesByTags (currentTag)
88+ window .scrollTo (0 , 0 )
89+ },
90+
8291 // 根据分类获取页面数据
8392 getPagesByTags (currentTag ) {
8493 this .currentTag = currentTag
@@ -96,19 +105,23 @@ export default {
96105 // reverse()是为了按时间最近排序排序
97106 this .posts = posts .length == 0 ? [] : posts
98107
99- this .getCurrentPage (1 )
108+ this ._setPage (1 )
100109 },
101110
102111 getCurrentTag (tag ) {
103112 this .$emit (' currentTag' , tag)
104113 },
105114
106115 getCurrentPage (page ) {
116+ this ._setPage (page)
117+ setTimeout (() => {
118+ window .scrollTo (0 , 0 )
119+ }, 100 )
120+ },
121+ _setPage (page ) {
107122 this .currentPage = page
108123 this .$page .currentPage = page
109- window .scrollTo (0 , 0 )
110124 },
111-
112125 // 获取时间的数字类型
113126 _getTimeNum (date ) {
114127 return parseInt (new Date (date .frontmatter .date ).getTime ())
Original file line number Diff line number Diff line change 11{
22 "name" : " vuepress-theme-reco" ,
3- "version" : " 1.0.9-alpha.3 " ,
3+ "version" : " 1.0.9-alpha.6 " ,
44 "description" : " this is a vuepress theme" ,
55 "main" : " index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments