【问题标题】:react-native-webview in React Native not scrolling for AndroidReact Native 中的 react-native-webview 不能为 Android 滚动
【发布时间】:2020-07-20 04:22:40
【问题描述】:

我正在我的 react-native-webview 应用程序的 react-native-webview 中加载一个网页。在 iOS 中,一切正常,我可以向下滚动网页。但问题正在Android中发生。它不允许滚动网页。这是我的代码

<WebView 
       style={{ 
                height:1000,        
                flex: 1,
                fontFamily:'TitilliumWeb-SemiBold',
                   color:'#38c654',
                    fontSize:15,
                    width:'100%',
                    marginTop:5,
                    backgroundColor:'transparent',
              }}
                    
                    
             originWhitelist={['*']}
             scalesPageToFit={true}
             javaScriptEnabled={true}
             domStorageEnabled={true}
             startInLoadingState={true}
             renderLoading={() => {
                 return this.displaySpinner();
             }}
                  
             source={{
                     uri: URLLink
                    }}
             /> 

之后,我用谷歌搜索并找到了另一个库 react-native-autoheight-webview。我也使用了它,但我仍然无法在 Android 中滚动网页。对此的任何解决方案都会有很大帮助。

【问题讨论】:

    标签: html react-native webview


    【解决方案1】:

    也许这个可注入的代码块对你有帮助。

    injectedJavaScript={`const meta = document.createElement('meta'); 
    meta.setAttribute('content', 'width=device-width, initial-scale=0.5, maximum- 
    scale=0.5, user-scalable=0'); meta.setAttribute('name', 'viewport'); 
    document.getElementsByTagName('head')[0].appendChild(meta); `}
    scalesPageToFit={false}
    

    【讨论】:

      猜你喜欢
      • 2020-09-25
      • 2017-10-02
      • 1970-01-01
      • 2018-08-15
      • 2020-12-13
      • 1970-01-01
      • 2018-06-25
      • 1970-01-01
      • 2018-09-04
      相关资源
      最近更新 更多