File tree 2 files changed +19
-5
lines changed
2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 67
67
</template >
68
68
69
69
<script lang="ts">
70
- import { IonHeader , IonToolbar , useIonRouter } from ' @ionic/vue' ;
70
+ import {
71
+ IonHeader ,
72
+ IonToolbar ,
73
+ useBackButton ,
74
+ useIonRouter ,
75
+ } from ' @ionic/vue' ;
71
76
import { computed , defineComponent } from ' vue' ;
72
77
import { useStore } from ' vuex' ;
73
78
import { useRoute } from ' vue-router' ;
@@ -189,6 +194,8 @@ export default defineComponent({
189
194
ionRouter .navigate ({ name: currentHomeRouteName .value }, ' back' , ' push' );
190
195
}
191
196
197
+ useBackButton (1 , back );
198
+
192
199
return {
193
200
UNFINISHED_FEATURES ,
194
201
homeRouteName ,
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ import {
82
82
onBeforeUnmount ,
83
83
onMounted ,
84
84
} from ' vue' ;
85
+ import { BackButtonEvent } from ' @ionic/vue' ;
85
86
import { IS_FIREFOX , IS_EXTENSION } from ' @/constants' ;
86
87
import BtnClose from ' ./buttons/BtnClose.vue' ;
87
88
import FixedScreenFooter from ' ./FixedScreenFooter.vue' ;
@@ -108,17 +109,23 @@ export default defineComponent({
108
109
setup(props , { slots , emit }) {
109
110
const showHeader = computed (() => props .hasCloseButton || props .header || slots .header );
110
111
112
+ function handleClose() {
113
+ emit (' close' );
114
+ }
115
+
116
+ function onBackButtonHandler(event : BackButtonEvent ) {
117
+ event .detail .register (100 , handleClose );
118
+ }
119
+
111
120
onMounted (() => {
121
+ document .addEventListener (' ionBackButton' , onBackButtonHandler );
112
122
if (! document .body .style .overflow ) {
113
123
document .body .style .overflow = ' hidden' ;
114
124
}
115
125
});
116
126
117
- function handleClose() {
118
- emit (' close' );
119
- }
120
-
121
127
onBeforeUnmount (() => {
128
+ document .removeEventListener (' ionBackButton' , onBackButtonHandler );
122
129
document .body .style .overflow = ' ' ;
123
130
});
124
131
You can’t perform that action at this time.
0 commit comments