Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 未在NavigationStateChange本地web视图上更新URL {this.refWeb=webView;} 风格={{ 高度:高度,, 为内容辩护:“中心”, 对齐项目:“居中”, }} scrollEnabled={true} //加载URL 来源={ { uri:initialUrl, } } //启用Javascript支持 javaScriptEnabled={true} domStorageEnabled={true} injectedJavaScript={injectScript} automaticallyAdjustContentInsets={true} startInLoadingState={true} onNavigationStateChange={this.onNavigationStateChange}/> onNavigationStateChange=(navState)=>{ console.log(navState); if(navState.url==initialUrl){ 这是我的国家({ canGoBack:navState.canGoBack, canGoForward:navState.canGoForward, 钱德:错 }) }否则{ 这是我的国家({ canGoBack:navState.canGoBack, canGoForward:navState.canGoForward, 是的 }) } }_React Native_Webview_Single Page Application_Angular Universal - Fatal编程技术网

React native 未在NavigationStateChange本地web视图上更新URL {this.refWeb=webView;} 风格={{ 高度:高度,, 为内容辩护:“中心”, 对齐项目:“居中”, }} scrollEnabled={true} //加载URL 来源={ { uri:initialUrl, } } //启用Javascript支持 javaScriptEnabled={true} domStorageEnabled={true} injectedJavaScript={injectScript} automaticallyAdjustContentInsets={true} startInLoadingState={true} onNavigationStateChange={this.onNavigationStateChange}/> onNavigationStateChange=(navState)=>{ console.log(navState); if(navState.url==initialUrl){ 这是我的国家({ canGoBack:navState.canGoBack, canGoForward:navState.canGoForward, 钱德:错 }) }否则{ 这是我的国家({ canGoBack:navState.canGoBack, canGoForward:navState.canGoForward, 是的 }) } }

React native 未在NavigationStateChange本地web视图上更新URL {this.refWeb=webView;} 风格={{ 高度:高度,, 为内容辩护:“中心”, 对齐项目:“居中”, }} scrollEnabled={true} //加载URL 来源={ { uri:initialUrl, } } //启用Javascript支持 javaScriptEnabled={true} domStorageEnabled={true} injectedJavaScript={injectScript} automaticallyAdjustContentInsets={true} startInLoadingState={true} onNavigationStateChange={this.onNavigationStateChange}/> onNavigationStateChange=(navState)=>{ console.log(navState); if(navState.url==initialUrl){ 这是我的国家({ canGoBack:navState.canGoBack, canGoForward:navState.canGoForward, 钱德:错 }) }否则{ 这是我的国家({ canGoBack:navState.canGoBack, canGoForward:navState.canGoForward, 是的 }) } },react-native,webview,single-page-application,angular-universal,React Native,Webview,Single Page Application,Angular Universal,我正在使用react native webview,但onNavigationStatechange未更新navState url。单击webview内的内部链接时,它保持不变 还了解了由于单页应用程序引起的一些问题,有人能建议处理和克服此问题的方法吗。您能给我看一下代码吗?@hongdevelop在上面的代码navState.url中保持不变,但是我在webview中的页面发生了变化。您看到navState包含什么了吗?@hongdevelop我的navState包含相同的url(initia

我正在使用react native webview,但onNavigationStatechange未更新navState url。单击webview内的内部链接时,它保持不变


还了解了由于单页应用程序引起的一些问题,有人能建议处理和克服此问题的方法吗。

您能给我看一下代码吗?@hongdevelop在上面的代码navState.url中保持不变,但是我在webview中的页面发生了变化。您看到navState包含什么了吗?@hongdevelop我的navState包含相同的url(initialUrl)injectedJs`let initialUrl=window.location.href;现在解决了它的不可更新编辑问题;让checkUrlChange=()=>{const currentUrl=window.location.href;if(currentUrl!==initialUrl){window.reactiveWebView.postMessage(“{\”locationUpdated\”:\”'+currentUrl+“\”}');initialUrl=currentUrl;}}setInterval(checkUrlChange,2000)`你能给我看一下代码吗?@hongdevelop在上面的代码navState.url中保持不变,但是我在webview中的页面发生了变化。你看到navState包含什么了吗?@hongdevelop我的navState包含相同的url(initialUrl)它的未更新编辑现在由injectedJs`let initialUrl=window.location.href;让checkUrlChange=()=>{const currentUrl=window.location.href;if(currentUrl!==initialUrl){window.reactiveWebView.postMessage(“{\”locationUpdated\”:\”'+currentUrl+“\”}');initialUrl=currentUrl;}}setInterval(checkUrlChange,2000)`
        <WebView
          ref={webView => { this.refWeb = webView; }}
          style={{
            height:height,
            justifyContent: 'center',
            alignItems: 'center',
          }}
         scrollEnabled={true}
          //Loading URL
          source={
            {
              uri: initialUrl,  
            }
          }
          //Enable Javascript support
          javaScriptEnabled={true}
          domStorageEnabled={true}}
          injectedJavaScript={injectScript} 
          automaticallyAdjustContentInsets = {true}
          startInLoadingState={true}
          onNavigationStateChange={this.onNavigationStateChange}/>  

     onNavigationStateChange = (navState) => {

          console.log(navState);
            if(navState.url===initialUrl){
                this.setState({
                canGoBack: navState.canGoBack,
                canGoForward: navState.canGoForward,
                changedUrl:false
                })
                }else{
                this.setState({
                canGoBack: navState.canGoBack,
                canGoForward: navState.canGoForward,
                changedUrl : true
        })
       }
     }