Просмотр исходного кода

router 刷新后自动调整到页面顶部

reghao 2 лет назад
Родитель
Сommit
b58f598b3a
1 измененных файлов с 10 добавлено и 1 удалено
  1. 10 1
      src/router/index.js

+ 10 - 1
src/router/index.js

@@ -7,6 +7,7 @@ const TimelineIndex = () => import('views/home/Timeline')
 const StatusPage = () => import('views/home/Status')
 const VideoIndex = () => import('views/home/Video')
 const VideoPage = () => import('views/home/VideoPage')
+const VideoList = () => import('views/home/VideoList')
 const LivePage = () => import('views/home/LivePage')
 const AudioIndex = () => import('views/home/Audio')
 const AudioPage = () => import('views/home/AudioPage')
@@ -127,6 +128,11 @@ const routes = [
     name: 'VideoPage',
     component: VideoPage
   },
+  {
+    path: '/vidlist/:id',
+    name: 'VideoList',
+    component: VideoList
+  },
   {
     path: '/live/:id',
     name: 'LivePage',
@@ -385,7 +391,10 @@ const routes = [
 // 创建路由对象
 const router = new VueRouter({
   mode: 'history',
-  routes
+  routes,
+  scrollBehavior(to, from, savedPosition) {
+    return { x: 0, y: 0 }
+  }
 })
 
 // 导出router