Open erleiuat opened 5 years ago
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
]
})
@erleiuat did you manage to solve this ?
I'm using programmatic navigation at some parts of my app, for example
this.$router.go(-1)
from the toolbar and with thebackbutton
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:
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.