I'm currently facing a challenge where I want to display two different views for the same path based on the presence of a token in LocalStorage. While I could easily handle this logic within each view itself, I'm exploring the possibility of achieving this directly in the Router.
Here's an example:
export default new Router({
mode: "history",
base: process.env.BASE_URL,
routes: [
{
path: "/",
name: "home",
component: function() {
if (...) {
return ViewA
} else {
return ViewB
}
}
},
]
});
I've attempted the above code but unfortunately, it didn't work as expected. The application builds without error, but neither of the two views is being displayed.