路由的基本配置
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()