What I want to achieve is that when accessing /self, it should first check if issignedin is true and then get the value of user.name to redirect. Those variables are set in Vue's data(){... part.
Nevertheless, I wasn't able to figure out, how I could access the data since the Vue Instance is created after I create the routes:
const routes = [
//...
{
path: "/self",
redirect: (to) => {
if (app.issignedin) {
return "/@" + user.name;
} else {
return "/login";
}
},
},
];
const router = new VueRouter({
routes,
});
const app = new Vue({
router: router,
data() {
return {
issignedin: true,
user: { name: "MoPaMo" },
//...
};
},
Neither this nor the name of the variable holding Vue (app) nor something like this.$parent works... :(
Help will be deeply appreciated!
/and I don't understand why any user would directly type/selfto land on your route before vue load