简体   繁体   中英

nativescript - How to simulate the Back button on a mobile app?

Currently I am working on a mobile application using Nativescript. I would like to simulate the Back button by clicking a component in my UI (when user clicks it it navigates back to previous screen).

Scenario:
Page 1 --> Page 2
Page 2 : click on component to go back to Page 1

Is there a way to do this?

Thanks for your time.

in pageB.js

var frameModule = require("ui/frame");
var topmost = frameModule.topmost();

function onTap() {
    topmost.goBack();
}

exports.onTap = onTap;

in pageB.xml

<Button text="BACK" tap="onTap" />

More detailed information at the following documentation article:

https://docs.nativescript.org/core-concepts/navigation#architecture-and-navigation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM