import Vue from 'vue' import VueRouter from 'vue-router' import { getSession } from './../util/item' import { Message } from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' // 页面引入 import Login from '@/views/login' import Index from '@/views/index' import CesiumVue from '@/views/CesiumCom/CesiumVue' const routerPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location) { return routerPush.call(this, location).catch(error => error) } Vue.use(VueRouter) // import axioss from 'axios' // import qs from 'qs' // Vue.prototype.$axios = axioss //全局注册,使用方法为:this.$axios // Vue.prototype.qs = qs //全局注册,使用方法为:this.qs const router = new VueRouter({ routes: [{ path: '/index', name: 'index', component: Index, children: [] }, { path: '/CesiumVue', name: 'CesiumVue', component: CesiumVue, children: [] }, { path: '/Login', name: 'login', component: Login }, { path: '/', redirect: '/Login' }, { path: '*', redirect: '/' }] }) // router.beforeEach((to, from, next) => { // /* 使用过程为, // 先判断vuex里面一条数据, // 判断是否登陆 */ // const that = this // if (to.name === 'login') { // next() // } else if (JSON.parse(getSession('logins')) === 'true') { // next() // } else { // Message({ // message: '请登录', // type: 'warning' // }); // next({ // 'path': '/Login' // }); // } // }); export default router