-
StackOverflow 文档
-
vuejs2 教程
-
路由
-
定义路线的不同方式
路线/ index.js
import About from '@/components/About'
const router = new Router({
routes: [
{
path: '/',
name: 'home',
component: {template: "<div>Home</div>"}
},
{
path: '/about',
component: About
},
require('./work').default,
// - NOT FOUND
{path: '/404', component: {template: "<div>404 not found.</div>"}},
{path: "/*", redirect: "/404"}
]
});
export default router
路线/ work.js
import Work from '@/components/Work/Work';
import Workitem from '@/components/Work/Workitem';
export default {
path: '/work',
name: 'work',
component: Work,
children: [
{path: '/all', component: {template: '<div>Some text</div>'}},
{path: ':id', name: 'work.view', component: Workitem},
{path: ':id/edit', name: 'work.edit', component: Workitemedit},
],
meta: {requiresAuth: true}
}