-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Labels
feature requestfixed on 4.xThis issue has been already fixed on the v4 but exists in v3This issue has been already fixed on the v4 but exists in v3group[dynamic routing]Issues regarding dynamic routing support (eg add, replace, remove routes dynamically)Issues regarding dynamic routing support (eg add, replace, remove routes dynamically)
Description
I am building a large scale application with "mini applications" hosted within the application.
Each mini application is being developed by another team.
I would like to dynamically add nested child routes to an existing route to allow dynamic registration of each of the mini apps.
for example:
const routes = [
{path: 'a', component: ComponentA, name: 'a'},
{path: 'b', component: ComponentB, name: 'b'},
];
//MiniApp.js
export default Vue.extend({
beforeCreate () {
this.$router.addChildRoutes(this.$router.currentRoute.path, routes);
},
template: `
<div>
<div class="page-host">
<router-link to="{name: 'a'}">a</router-link>
<router-link to="{name: 'b'}">b</router-link>
<transition name="fade" mode="out-in">
<keep-alive><router-view class="view"></router-view></keep-alive>
</transition>
</div>
</div>`,
});
//The app itself
Vue.use(Router);
import MiniApp from "./MiniApp";
const config = {
linkActiveClass: 'active',
scrollBehavior: () => ({x: 0, y: 0}),
routes: [
{path: '/mini', component: MiniApp, name: 'mini'}},
]
};
let router = new Router(config);
const vue = new Vue({
router,
template: `
<div>
<div class="page-host">
<router-link to="/mini">a</router-link>
<transition name="fade" mode="out-in">
<keep-alive><router-view class="view"></router-view></keep-alive>
</transition>
</div>
</div>`,
}).$mount('#app');
natizlp, newlife, rottmann, zipme, ilya-merkushin and 40 more
Metadata
Metadata
Assignees
Labels
feature requestfixed on 4.xThis issue has been already fixed on the v4 but exists in v3This issue has been already fixed on the v4 but exists in v3group[dynamic routing]Issues regarding dynamic routing support (eg add, replace, remove routes dynamically)Issues regarding dynamic routing support (eg add, replace, remove routes dynamically)