问题
I am testing with vue-router and come across this problem, what if i have two named views but i only want to change one of it without changing the default view. Currently I do it like this:
const router = new VueRouter({
routes: [
{
path: '/',
components: {
default: Foo,
change: Bar,
}
}
{
path: '/foo/test1',
components: {
default: Foo,
change: test1,
}
}
//is it possible to do it something like this?
{
path: '/:foo/test1',
components: {
default: :foo//<--- how to keep default to whatever it previously have?
change: test1
}
}
]
})
<router-view></router-view>
<router-view name="change"></router-view>
I think i can do this with dynamic matching, get the current route name and pass it as param, but I need to keep the current default route (like some form inputs), so i'd rather want to change only one of the views without affecting the others... please help...
来源:https://stackoverflow.com/questions/47666624/vue-router-change-only-one-of-the-named-view-without-affecting-the-others