123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- // //创建一个路由器
- 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';
- import result from '@/view/result.vue';
- const router = createRouter({
- history: createWebHashHistory(),
- routes: [
- {
- path: '/myHome',
- component: () => import('@/components/myHome.vue') // 这是路由的籁加载,也可以其他方式
- },
- {
- path: '/configurator',
- name:'模型库',
- component: configurator,// 这是路由的籁加载,也可以其他方式
- beforeEnter: (to, from,next) => {
- console.log(to, from);
- next()
- },
-
- },
- {
- path: '/',
- name:'首页',
- component: () => import('@/view/home.vue'),
- meta:{
- keepAlive:false, // 需要缓存
- title: '首页'
- }
- },
- {
- path: '/myHome',
- name:'首页1',
- component: () => import('@/view/myHome.vue'),
- meta:{
- keepAlive:false, // 需要缓存
- title: '首页1'
- }
- },
- {
- path: '/appmian',
- name:'主页',
- component: () => import('@/view/appmian.vue'),
- meta:{
- keepAlive:false, // 需要缓存
- title: '主页'
- },
- children: [
- // 这里可以定义子路由,它们将在Home组件的<RouterView>内渲染
- {
- path: '/myHome',
- name:"myhome",
- component: () => import('@/view/myHome.vue')
- }
- ]
- },
- {
- 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;
|