import Vue from 'vue';
import Router from 'vue-router';
import Home from './containers/Home.vue';
import DatePicker from './containers/DatePicker.vue';
import SearchItem from './containers/SearchItem.vue';
import Pagination from './containers/Pagination.vue';

Vue.use(Router);

export const routerMap = [
  { path: '/', name: 'Home', component: Home, meta: { title: '首页' } },
  {
    path: '/DatePicker',
    name: 'DatePicker',
    component: DatePicker,
    meta: { title: '时间选择' },
  },
  {
    path: '/layout',
    name: 'layout',
    meta: { title: '列表布局' },
    component: { render: h => <router-view /> },
    children: [
      {
        path: 'SearchItem',
        name: 'SearchItem',
        component: SearchItem,
        meta: { title: '搜索栏' },
      },
    ],
  },
  {
    path: '/baseCom',
    name: 'baseCom',
    component: { render: h => <router-view /> },
    meta: { title: '基础组件' },
    children: [
      {
        path: 'Pagination',
        name: 'Pagination',
        component: Pagination,
        meta: { title: '分页器' },
      },
    ],
  },
];

export default new Router({
  // mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: routerMap,
});
