<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="vue.js"></script>
<script src="vue-router.js"></script>
</head>
<body>
<div id="app">
<router-link to='/count'>come</router-link>
<h3>这是count组件</h3>
<router-view></router-view>
</div>
<template id="count">
<div>
<!--嵌套路由-->
<router-link to='/count/login'>登录</router-link>
<router-link to='/count/register'>注册</router-link>
<router-view></router-view>
</div>
</template>
<script>
var count = {
template: '#count'
}
var login={
template:'<h3>登录组件</h3>'
}
var register={
template:'<h3>注册组件<h3>'
}
var route = new VueRouter({
routes: [
{path: '/count',
component: count,
children:[{path:'login', component:login} ,{path:'register', component:register}]
}]
})
var vu = new Vue({
el: '#app',
data: {},
methods: {},
comments: {},
router: route
})
</script>
</body>
</html>
vue-route 嵌套路由
最新推荐文章于 2024-04-29 23:47:56 发布