[Vuejs]-Vue.js โ€“ Initialise a variable on page load

0๐Ÿ‘

Iโ€™ve figured it out. Using the created hook I also initialised currentPage with window.location.pathname, which initialises currentPage the current URL pathname. My initialising method now looks like

initialise: function() {
    if (this.currentPage=="/profile.html") {
        this.getNightmode();
        this.getProfile();
        this.getTaskTypes();
    } else if (this.currentPage=="/post_registration.html") {
        this.getSignUpMethod();
        this.getAccountType();
        this.getTaskTypes();
    }
}

And this calls the correct initialising methods according to the page.

Leave a comment