【发布时间】:2020-04-09 08:04:27
【问题描述】:
我有以下 WebView 组件,它多次用于新闻文章中的各种嵌入
<WebView
useWebKit={true}
ref={(ref) => this.webview = ref}
javaScriptEnabled={true}
injectedJavaScript={"(" + injectedScript + ")()"}
onMessage={this.onMessage}
onNavigationStateChange={this.onNavigationStateChange}
{...this.props}
/>
以及以下导航状态变化监听器,用于在外部浏览器中打开链接
onNavigationStateChange = (event) => {
this.webview.stopLoading();
Linking.openURL(event.url);
}
问题在于导航更改侦听器似乎无法区分用户交互和自动页面重定向(社交媒体嵌入通常会这样做)。如何在外部浏览器中打开链接,仅用于用户交互?
【问题讨论】:
标签: react-native webview