Skip to content

Commit a2c98aa

Browse files
committed
only scroll to top when switching pages
1 parent a98df0c commit a2c98aa

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

build/build.js

+7-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/build.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/views/news-view.vue

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ module.exports = {
2828
}
2929
},
3030
watch: {
31-
'params.page': 'update'
31+
'params.page': function () {
32+
this.update(true)
33+
}
3234
},
3335
compiled: function () {
3436
this.update()
@@ -41,11 +43,13 @@ module.exports = {
4143
item: require('../components/item.vue')
4244
},
4345
methods: {
44-
update: function () {
46+
update: function (switchingPage) {
4547
store.fetchItemsByPage(this.params.page, function (items) {
4648
this.items = items
4749
this.displayPage = this.params.page
48-
window.scrollTo(0, 0)
50+
if (switchingPage) {
51+
window.scrollTo(0, 0)
52+
}
4953
}.bind(this))
5054
}
5155
}

0 commit comments

Comments
 (0)