Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue-router programmatic navigation #82

Open
erleiuat opened this issue Sep 30, 2019 · 2 comments
Open

Vue-router programmatic navigation #82

erleiuat opened this issue Sep 30, 2019 · 2 comments

Comments

@erleiuat
Copy link

erleiuat commented Sep 30, 2019

I'm using programmatic navigation at some parts of my app, for example this.$router.go(-1) from the toolbar and with the backbutton callback from cordova.

While normal navigation with router.push({name: 'xyz'}) is working properly, navigating back doesn't seem to work (same when modifying the history directly). Now I don't know if this issue is directly related to the plugin, but I couldn't find similar issues somewhere else. So if someone knows where this belongs instead, I'd be grateful to know.

My router config is set to hash mode as it should be and this is my vue.config.js for cordova:

module.exports = {
    publicPath: '',

    pluginOptions: {
        cordovaPath: 'src-cordova'
    }
}

As far as I observed the window.history is being modified successful when navigating back. But there is no navigation being done by vue-router itself therefore the view won't be changed.

@erleiuat
Copy link
Author

Example using 'backbutton' callback:

if (process.env.CORDOVA_PLATFORM) {
    document.addEventListener('backbutton', () => {
        this.$router.go(-1)
     }, false)
}

Router Config:

const router = new Router({
    mode: process.env.CORDOVA_PLATFORM ? "hash" : "history",
    base: process.env.BASE_URL,
    scrollBehavior (to, from, savedPosition) {
        return { x: 0, y: 0 }
    },
    routes: [
        ...main,
        ...auth,
        ...app,
        ...premium
    ]
})

@vesper8
Copy link

vesper8 commented Nov 30, 2019

@erleiuat did you manage to solve this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants