Skip to content

Commit 8ff10e3

Browse files
committed
refactor: add back button handler to sample - optional
1 parent a101fac commit 8ff10e3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

samples/app/app-with-router-v2.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const Vue = require('./nativescript-vue')
22
const VueRouter = require('vue-router')
3+
const application = require('tns-core-modules/application')
34

45
Vue.config.silent = false
56
Vue.config.debug = true
@@ -58,6 +59,15 @@ const router = new VueRouter({
5859

5960
router.push('/')
6061

62+
application.android &&
63+
application.android.on(
64+
application.AndroidApplication.activityBackPressedEvent,
65+
event => {
66+
event.cancel = true
67+
router.go(-1)
68+
}
69+
)
70+
6171
new Vue({
6272
router,
6373
template: `

0 commit comments

Comments
 (0)