我正在尝试使用 Xamarin forms webview .Navierated
事件来检测 react 应用程序中页面位置何时发生变化。然而,它似乎只在我导航到外部页面时发出,而不是在 react 应用程序内发出,即使我使用的是 react 路由器。在我的浏览器中,url 发生变化,但 Xamarin webview 不会注册该更改,即使我通过打印 webView.Source
手动轮询 url。
有什么方法可以从 C# 检测 React 应用程序内的导航吗?
最佳答案
如果您希望组件具有位置感知能力,您可以使用 HoC withRouter 包装它。由React Router提供.
You can get access to the history object’s properties and the closest
<Route>
's match via the withRouter higher-order component. withRouter will re-render its component every time the route changes with the same props as render props: { match, location, history }.
在 React 应用程序中获取位置更改更新后,您可以更新 C# 以执行您需要的任何操作。
编辑:解决您的评论...
现在我从未使用过 C#,但根据我的研究,这应该可行......看看 __doPostBack
。您可以阅读如何使用它 here .
关于reactjs - Xamarin ReactJS WebView 导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45120871/