35
35
</span >
36
36
</div >
37
37
</div >
38
- <a href =" #2.2" >点击跳转</a >
39
38
<note >
40
39
<p >{{ article.abstract }}</p >
41
40
</note >
50
49
<prevnext :article =" article" ></prevnext >
51
50
</div >
52
51
<div class =" article-detail__comment" >
52
+ <a id =" a_cm" ></a >
53
53
<div class =" comment__title" >
54
54
<i class =" el-icon-chat-dot-round" ></i >
55
55
<span >文章评论</span >
@@ -87,6 +87,14 @@ import submit from '@/views/components/submit'
87
87
import copyright from ' ./components/copyright'
88
88
import share from ' ./components/share'
89
89
import prevnext from ' ./components/prevnext'
90
+
91
+ function jumpAnchor (route ) {
92
+ if (route .query .anchor === ' a_cm' ) {
93
+ const el = document .querySelector (' #a_cm' )
94
+ el .scrollIntoView ()
95
+ }
96
+ }
97
+
90
98
export default {
91
99
name: ' articleDetail' ,
92
100
components: { note, comments, submit, copyright, share, prevnext },
@@ -118,10 +126,11 @@ export default {
118
126
Prism .highlightAll ()
119
127
})
120
128
this .collectTitles ()
129
+
121
130
window .addEventListener (' scroll' , this .handleScroll , false )
122
131
},
123
132
updated () {},
124
- async asyncData ({ route }) {
133
+ async asyncData ({ route, isServer }) {
125
134
const articleRes = await api .getArticle ({
126
135
publish: 1 ,
127
136
articleId: route .params .id
@@ -132,6 +141,7 @@ export default {
132
141
articleId: route .params .id
133
142
})
134
143
if (articleRes .status === 200 ) {
144
+ if (! isServer) setTimeout (() => jumpAnchor (route), 0 )
135
145
return { article: articleRes .data , messages: commentRes .data , total: commentRes .total }
136
146
}
137
147
},
0 commit comments