【问题标题】:Does expo, problem with webview, it show page blank screen世博会,webview有问题,它显示页面空白屏幕
【发布时间】:2021-08-10 22:29:44
【问题描述】:

货币我正在使用 React Native 和 expo,昨天我正在使用 WebView,但是我的项目显示黑屏,当我编译我的项目时,我通过手机看到了所有内容,我已经尝试了所有方法来解决它,但我没有成功,有人可以帮我吗?,我不知道该怎么办。

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { WebView } from 'react-native-webview';

const styles = StyleSheet.create({
 container: {
  flex: 1,
  backgroundColor: '#fff',
  alignItems: 'center',
  justifyContent: 'center',
 },
});

export default function App(){
  return (
    <View style={styles.container}>
    <h1>Test</h1>
    <Text>Test text</Text>
    <WebView
      source={{ uri: 'https://www.youtube.com' }}
    />
    </View>
   );
}

这是我的 package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
  "start": "expo start",
  "android": "expo start --android",
  "ios": "expo start --ios",
  "web": "expo start --web",
  "eject": "expo eject"
},
"dependencies": {
  "expo": "~41.0.1",
  "expo-status-bar": "~1.0.4",
  "react": "17.0.2",
  "react-dom": "17.0.2",
  "react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz",
  "react-native-web": "~0.16.3",
  "react-native-webview": "11.2.3"
},
"devDependencies": {
  "@babel/core": "^7.14.3"
},
"private": true

【问题讨论】:

    标签: react-native expo


    【解决方案1】:

    复制粘贴到 Snack.expo.io

    我有点不清楚你的问题到底是什么,但这会使网页在 android 和 iphone 上都很好。

    导致白屏的问题是样式。如果去掉 flex: 1 之外的样式,它会完全渲染。

    export default function App(){
      return (
        <WebView
          source={{ uri: 'https://www.youtube.com' }}
        />
       );
    }
    

    【讨论】:

    • 谢谢,但和我的代码一样
    • 这告诉你它可能在你的造型中,我会尝试从我给你的东西重新开始,然后从那里开始造型,同时确保每次有机会它仍然有效。您还应该更清楚地说明您的问题。
    • 对不起,也许我不干净,因为我不会说英语,我还在学习,但我会照你说的做,再次感谢
    【解决方案2】:

    也有这个问题,我注意到如果我使用 github 文档上的示例,它会加载视频,但目前无法呈现 html 或网页:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-17
      • 2013-08-25
      • 1970-01-01
      • 2014-02-12
      • 2014-01-13
      • 2022-01-23
      • 2021-07-19
      • 1970-01-01
      相关资源
      最近更新 更多