import React from 'react';
import {StyleSheet, Text, View, WebView} from 'react-native';
export default class App extends React.Component {
constructor(props){
super(props);
this._webview = null;
}
_onNavigationStateChange(webViewState){
console.log(webViewState.url);
var no=Math.random();
console.log(no);
if (no>0.5){
console.log("found");
this._webview.stopLoading();
}
return true;
}
render(){
return (
<WebView
ref={component => this._webview = component}
source={{uri: 'https://www.google.com/search?ei=DI9ZXMTAMtb-rQGFwaDYDw&q=web+development+company+in+delhi&oq=web+development+company+in+delhi&gs_l=psy-ab.3..35i39j0j0i7i30l4j0i5i30l4.32946.34428..34777...0.0..0.220.1407.0j8j1......0....1..gws-wiz.......0i71j35i304i39j0i13j0i7i5i30.WD85QRQKyog'}}
onNavigationStateChange={
this._onNavigationStateChange.bind(this)
}
javaScriptEnabled = {true}
domStorageEnabled = {true}
startInLoadingState={false}
/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
一旦我停止使用webview加载。停止加载它不允许打开任何其他链接。无链接再次处于活动状态。
在我的情况下,它会打开谷歌链接,当我选择一个链接时,没有>0.5然后我停止加载即将打开的页面,但此后我无法打开任何其他链接