123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- // //创建一个路由器
- import { createRouter, createWebHashHistory, } from "vue-router";
- import configurator from "@/view/configurator.vue"
- import resultLeft from '@/view/result/resultLeft.vue';
- import resultRight from '@/view/result/resultRight.vue';
- const home = () => import("@/views/home/index.vue")
- import result from '@/view/result.vue';
- const router = createRouter({
- history: createWebHashHistory(),
- routes: [
- {
- path: '/configurator',
- name:'模型库',
- component: configurator,// 这是路由的籁加载,也可以其他方式
- beforeEnter: (to, from,next) => {
- console.log(to, from);
- next()
- },
-
- },
- {
- path: '/vtk',
- name:'案例',
- component: () => import('@/view/vtk/vtk.vue'),// 这是路由的籁加载,也可以其他方式
-
- },
- {
- path: '/vtk2',
- name:'案例1',
- component: () => import('@/view/vtk/vtk2.vue'),// 这是路由的籁加载,也可以其他方式
-
- },
- {
- path: '/demo',
- name:'案例3',
- component: () => import('@/view/vtk/demo.vue'),// 这是路由的籁加载,也可以其他方式
-
- },
- // {
- // path: '/',
- // name:'首页',
- // component: () => import('@/view/home.vue'),
- // meta:{
- // keepAlive:false, // 需要缓存
- // title: '首页'
- // }
- // },
-
- {
- path: '/login',
- name: 'login',
- component: () => import('@/view/login.vue'), // 登录页面组件
- },
- {
- path: '/',
- name:'煤矿灾害态势推演',
- component: () => import('@/view/appmian.vue'),
- meta:{
- keepAlive:false, // 需要缓存
- title: '煤矿灾害态势推演'
- },
- children:[
- {
- path: '/home',
- name: 'home',
- component: () => import('@/views/home/index.vue'),
- }
- ]
-
- },
- // {
- // path: "/home",
- // name: "home",
- // component: home
- // },
- // {
- // path: '/home',
- // name:'局部',
- // component: () => import( "@/views/home/index.vue"),
- // meta:{
- // keepAlive:false, // 需要缓存
- // title: '局部'
- // },
-
- // },
- {
- path: '/goods',
- name: 'goods',
- component: {
- // 这里的 goods 对应 router-view 中的 name
- goods: resultLeft
- }
- },
- {
- path: '/orderinfo',
- name: 'orderinfo',
- component: {
- // 这里的 orderinfo 对应 router-view 中的 name
- orderinfo:resultRight
- }
- }
-
- // {
- // path: '/resultLeft',
- // name:'resultLeft',
- // component: resultLeft,// 这是路由的籁加载,也可以其他方式
- // },
- // {
- // path: '/resultRight',
- // name:'resultRight',
- // components:{
- // resultRight:resultRight
- // } // 这是路由的籁加载,也可以其他方式
- // },
-
- ]
- })
- //修改动态网页标题 beforeEach 导航钩子,路由改变前触发
- router.beforeEach((to,from,next) =>{
- //window.document.title = to.meta.title;
- window.document.title = to.name;
- next();
- })
- router.afterEach((to,from,next) =>{
- window.scrollTo(0,0);
- })
- export default router;
|