12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- // 从路由库中导出创建方法
- import {createRouter,createWebHistory,createWebHashHistory} from 'vue-router';
- // 引入页面
- import Home from '../views/Home.vue';
- import My from '../views/My.vue';
- import List from '../views/List.vue';
- import Detail from '@/views/Detail.vue';
- import Hi from '@/components/Hi.vue';
- import Demo2 from '@/components/Demo2.vue';
- const router = createRouter({
- // 模式
- history: createWebHistory(),
- routes: [
- {
- path: '/',
- redirect:'/home'
- },
- {
- path:'/home',
- component: Home
- },
- {
- // path:'/detail/:id/:name',
- path:'/detail',
- component: Detail,
- name:'xiangqing'
- },
- {
- path:'/list',
- component: List,
- children:[
- {
- path:'',
- redirect:"/list/demo1"
- },
- {
- path:'demo1',
- component: Hi,
- // name:'nanzhuang'
- },
- {
- path:'demo3',
- component: ()=>import('../components/Demo3.vue'),
- // name:'nanzhuang'
- },
- {
- path:'demo2',
- // path:'demo2/:id/:name1',
- component: Demo2,
- // name:"nvzhuang"
- }
- ]
- },
- {
- path:'/my',
- component: My,
- name:"wode"
- },
- ]
- });
- export default router;
|