中融router.js
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>订餐</title> <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0"> </head> <body> <input type="hidden" id="employee-id" value="<?=$employeeId?>"> <input type="hidden" id="vip" value="<?=$vip?>"> <div id="app">加载中</div> </body> </html>
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
{
path: '/',
redirect: to => {
// const { hash, params, query } = to
// if (query.to === 'foo') {
// return { path: '/foo', query: null }
// }
// if (hash === '#baz') {
// return { name: 'baz', hash: '' }
// }
if (document.getElementById('vip').value) {
return '/room'
} else {
return '/meal'
}
}
},
{
path: '/room',
component: (resolve) => require(['../pages/home/index.vue'], resolve),
meta: {
title: '预订包房',
order: 0
}
},
{
path: '/meal',
component: (resolve) => require(['../pages/meal/index.vue'], resolve),
meta: {
title: '点餐',
order: 1
}
},
{
path: '/user',
component: (resolve) => require(['../pages/user/index.vue'], resolve),
meta: {
title: '我的',
order: 2
}
}
]
// 路由配置
const router = new VueRouter({
routes
})
// router.beforeEach((to, from, next) => {
// next()
// })
//
// router.afterEach(() => {
// })
export default router
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export default new Router({
routes: [{
path: '/',
name: 'Home',
component: require('@/pages/Home').default
},
{
path: '*',
redirect: '/'
},
{
path: '/deliver',
name: 'Deliver',
component: require('@/pages/Deliver').default
},
{
path: '/working',
name: 'Working',
component: require('@/pages/Working').default
},
{
path: '/login',
name: 'Login',
component: require('@/pages/Login').default
},
{
path: '/manage',
component: require('@/pages/Manage').default,
children: [
{
path: '/',
name: 'Dashboard',
component: require('@/pages/manage/Dashboard').default
},
{
path: 'temperature',
name: 'Temperature',
component: require('@/pages/manage/Temperature').default
},
{
path: 'motor',
name: 'Motor',
component: require('@/pages/manage/Motor').default
},
{
path: 'aisle',
name: 'Aisle',
component: require('@/pages/manage/Aisle').default
},
{
path: 'setting',
name: 'Setting',
component: require('@/pages/manage/Setting').default
},
{
path: 'dev',
name: 'Dev',
component: require('@/pages/manage/Dev').default
}
]
},
]
})
import Vue from 'vue' //引入Vue
import Router from 'vue-router' //引入vue-router
import Hello from '@/components/Hello' //引入根目录下的Hello.vue组件
import Hi from '@/components/Hi'
Vue.use(Router) //Vue全局使用Router
export default new Router({
routes: [ //配置路由,这里是个数组
{ //每一个链接都是一个对象
path: '/', //链接路径
name: 'Hello', //路由名称,
component: Hello //对应的组件模板
},{
path:'/hi',
name:'Hi',
component:Hi
}
]
})