我如何从给定的URL中捕获事件React-Native WebView

时间:2020-07-20 06:30:54

标签: reactjs react-native react-native-webview

如何将事件侦听器添加到React-Native WebView。即,我如何从给定的URL捕获事件,我的代码在其无法正常工作的下面给出。

     let  INJECTEDJAVASCRIPT="window.addEventListener('callBack', function(event) {console.log(event,'lops')});true;"

         <WebView
            key={this.state.key}
            ref={(ref) => { this.webview = ref; }}
            source={{uri:this.state.url || this.props.url}}
            javaScriptEnabled = {true}
            domStorageEnabled = {true}
            startInLoadingState={false}
            showsHorizontalScrollIndicator={false}
            showsVerticalScrollIndicator={false}
            injectedJavaScript={INJECTEDJAVASCRIPT}
            style={styles.web}
           
          />

如果您有任何想法,请帮助我。 谢谢

0 个答案:

没有答案