【问题标题】:Is there a way to use webview.goBack and navigation.goBack using the same button in react native webview?有没有办法使用 webview.goBack 和 navigation.goBack 在反应原生 webview 中使用相同的按钮?
【发布时间】:2021-01-13 16:11:13
【问题描述】:
我正在开发一个使用 webview 的 react native 应用程序。我想使用一个后退按钮在 webview 中导航以及退出 webview 并返回到应用程序的主屏幕。
我知道 canGoBack 属性,但只有在导航到另一个域中的链接时才会触发 onNavigationStateChange 函数。
在同一域中的屏幕之间导航时,我可以通过什么方式实现相同的功能?
【问题讨论】:
标签:
android
react-native
webview
【解决方案1】:
在同一个按钮上单击检查
if (webview.goBack()){
// if web view has something to go back use it
}else{
navigation.goBack()
}