多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
``` <body> <div id="app"> <router-link to="/account">Account</router-link> <router-view></router-view> </div> <template id="tmp1"> <div> <h1>这是Account组件</h1> <router-link to="/account/login">登录</router-link> <router-link to="/account/register">注册</router-link> <router-view></router-view> </div> </template> <script> var account = { template: '#tmp1' } var login = { template: '<h3>登录</h3>' } var register = { template: '<h3>注册</h3>' } var router = new VueRouter({ routes: [ { path: '/account', component: account, //使用childer属性,实现子路由同时,子路由的path前面不要带/,否则永远以根路径开始请求 children: [ {path: 'login', component: login}, {path: 'register', component: register} ] } ] }) var vm = new Vue({ el: '#app', router: router }) </script> </body> ```