路由嵌套
页面结构
<body>
<div id="app">
<router-view></router-view>
<router-link to="/user">会员中心</router-link>
<router-link to="/user/address">会员中心下面的收货地址</router-link>
<br />
</div>
</body>
<script src="./vue.min.js"></script>
<script src="./vue-router.js"></script>
逻辑结构
const User = {
template:`
<div>
<h1>会员中心页面</h1>
<router-view></router-view>
</div>
`
}
const Address = {
template: `<h1>子路由收货地址页面</h1>`
}
const router = new VueRouter({
routes: [
{
path: '/user',
component: User,
children: [
{
path:'address',
component:Address
}
]
}
]
})
var app = new Vue({
el:'#app',
router
})