React Native Webview 处理 url 更改侦听器 [英] React Native Webview handle url change listener

查看:109
本文介绍了React Native Webview 处理 url 更改侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在 React Native Web 视图上处理 URL 更改.

it is possible to handle URL change on React Native web view.

我尝试使用 onNavigationStateChange 侦听器进行处理.但它只有一次发射.当页面加载时触发 onNavigationStateChange.当我导航到另一个页面时,此事件不会触发.

I try to handle with onNavigationStateChange listener. But it only once time firing. When the page is load firing onNavigationStateChange. And when I navigate to another page, this event not firing.

有什么想法吗?

推荐答案

我在 React Native WebView 中加载网站链接,当我点击它导航到默认移动浏览器时,它有按钮.

I load website link in react native WebView and its has button when i click that it navigate to default mobile browser.

在 react native android 当前场景中运行应用程序:当我点击网站中的按钮时,它导航到默认浏览器,但没有得到我在上述建议中尝试过的 url.

Running application in react native android Current scenario: when i click button in website its navigate to default browser and am not getting the url i tried above suggestions.

预期场景:当我点击网站上的那个按钮时,它不应该导航到默认浏览器,我想要那个在默认浏览器中打开的网址.

Expected scenario: When i click that button in website it should not navigate to default browser and i want that url which is opened in default browser.

my react version: "react-native": "0.64.0",

onLoadProgress = {({ nativeEvent }) => {
    //your code goes here       
}}
onNavigationStateChange={navState => {
    console.log("navState ", navState);
}}

这篇关于React Native Webview 处理 url 更改侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆