import { createRouter, createWebHashHistory, Router } from 'vue-router'; import Auth from '@/views/layout/auth'; const router: Router = createRouter({ history: createWebHashHistory(), routes: [ { path: '/', component: Auth, children: [ { path: '/lessonCourseware', name: 'lessonCourseware', component: () => import('@/views/lessonCourseware/index'), meta: { title: '云课堂' } }, { path: '/courseList', name: 'courseList', component: () => import('@/views/courseList/index'), meta: { title: '课件详情' } }, { path: '/coursewarePlay', name: 'coursewarePlay', component: () => import('@/views/coursewarePlay'), meta: { title: '课程播放' } }, { path: '/login', name: 'login', component: () => import('@/views/layout/login'), meta: { isRegister: false } } ] } ], scrollBehavior(to, form, savedPosition) { if (savedPosition) { return savedPosition; } else { return { left: 0, top: 0 }; } } }); // router.onError(error => { // if (error instanceof Error) { // const isChunkLoadFailed = error.name.indexOf('chunk'); // const targetPath = router.currentRoute.value.fullPath; // console.log(error); // if (isChunkLoadFailed) { // location.hash = targetPath; // window.location.reload(); // } // } // }); export default router;