1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import { createRouter, createWebHistory } from 'vue-router'
- // 其他路由将在对应页面组件创建后添加
- const routes = [
- {
- path: '/',
- name: 'Home',
- component: () => import('@/pages/home/Index.vue'),
- },
- {
- path: '/products',
- name: 'Products',
- component: () => import('@/pages/products/Index.vue'),
- },
- {
- path: '/cases',
- name: 'Cases',
- component: () => import('@/pages/cases/Index.vue'),
- },
- {
- path: '/casesdetails',
- name: 'Casesdetails',
- component: () => import('@/pages/casesdetails/Index.vue'),
- },
- {
- path: '/about',
- name: 'About',
- component: () => import('@/pages/about/Index.vue'),
- },
- {
- path: '/contact',
- name: 'Contact',
- component: () => import('@/pages/contact/Index.vue'),
- }
- ]
- const router = createRouter({
- history: createWebHistory(),
- routes,
- scrollBehavior(to, from, savedPosition) {
- // 如果有保存的位置(比如浏览器前进后退),则返回到保存的位置
- if (savedPosition) {
- return savedPosition
- }
- // 否则滚动到页面顶部
- return { top: 0 }
- }
- })
- export default router
|