라우팅 기본 구성
export const constantRoutes = [
{
path: '/',
redirect: '/home', // 重定向
component: Layout, // 头部组件和尾部组件在这儿
children: [
{
path: 'home', // 路径
component: () => import('@/views/home/Index'), // 文件所在位置
meta: { title: '首页' }
},
{
path: 'product/hardware',
component: () => import('@/views/product/Hardware.vue'),
meta: { title: '产品-智能硬件' }
},
}
]
맨 위로 스크롤 동작으로 돌아가기
router/index.js 파일에도 구성되어 있습니다.
const createRouter = () =>
new Router({
// mode: 'history', // require service support
// 返回顶部
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes
})
const router = createRouter()