简体   繁体   English

有没有办法使用 webview.goBack 和 navigation.goBack 在 react native webview 中使用相同的按钮?

[英]Is there a way to use webview.goBack and navigation.goBack using the same button in react native webview?

I'm working on a react native app which uses a webview.我正在开发一个使用 webview 的本机应用程序。 I want to use a single back button to navigate within the webview as well as to exit the webview and return to the homescreen of the app.我想使用单个后退按钮在 webview 中导航以及退出 webview 并返回到应用程序的主屏幕。 I'm aware of canGoBack property but the onNavigationStateChange function is fired only when navigating to a link in another domain.我知道 canGoBack 属性,但只有在导航到另一个域中的链接时才会触发 onNavigationStateChange 函数。 Any way i can can achieve the same functionality when navigating between screens in the same domain?在同一个域中的屏幕之间导航时,我可以通过什么方式实现相同的功能?

On same button click check在同一个按钮上单击检查

if (webview.goBack()){
  // if web view has something to go back use it
}else{
navigation.goBack()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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