vue-router 多层嵌套
转载于:http://blog.csdn.net/github_26672553/article/details/54861174<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><!-- <link rel="stylesheet" type="text
·
转载于:http://blog.csdn.net/github_26672553/article/details/54861174
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<!-- <link rel="stylesheet" type="text/css" href="../../css/reset.css"> -->
<script type="text/javascript" src="../vue/vue.min.js"></script>
<script type="text/javascript" src="../vue/vue-router.min.js"></script>
<script type="text/javascript" src="../vue/babel.min.js"></script>
</head>
<body style="padding:30px">
<div id="box">
<router-link to="/Home">Home</router-link>
<router-link to="/News">News</router-link>
<router-view></router-view>
</div>
<template id="Home">
<div>
<div>Home</div>
<router-link to="/Home/login">login</router-link>
<router-link to="/Home/register">register</router-link>
<router-view></router-view>
</div>
</template>
<template id="News">
<div>News</div>
</template>
<template id="Login">
<div>login</div>
</template>
<template id="Register">
<div>register</div>
</template>
</body>
</html>
<script>
const Home = { template: '#Home' };
const News = { template: '#News' };
const Register = { template: '#Register' };
const Login = { template: '#Login' };
const routes = [
{ path: '/', redirect: '/Home' },
{
path: '/Home',
component: Home,
name: 'Home',
children: [
{ path: '/Home', redirect: '/Home/login' },
{ path: '/Home/login', component: Login },
{ path: '/Home/register', component: Register }
]
},
{ path: '/News', component: News, name: 'News' }
];
const router = new VueRouter({
routes
});
const vm = new Vue({
el: '#box',
router
})
</script>
更多推荐
已为社区贡献6条内容
所有评论(0)