React native 我在expo中的第一个react本机代码:需要在5秒内添加启动屏幕

React native 我在expo中的第一个react本机代码:需要在5秒内添加启动屏幕,react-native,webview,expo,React Native,Webview,Expo,这是我能够成功运行的第一个expo代码: import * as React from 'react'; import { Text, View, StyleSheet } from 'react-native'; import Constants from 'expo-constants'; import { WebView } from 'react-native-webview'; // You can import from local files import AssetExampl

这是我能够成功运行的第一个expo代码:

import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import Constants from 'expo-constants';
import { WebView } from 'react-native-webview';

// You can import from local files
import AssetExample from './components/AssetExample';

// or any pure javascript modules available in npm
import { Card } from 'react-native-paper';

export default function App() {
  return (
    <WebView
        style={{ marginTop: 0 }}
        source={{ uri: 'https://baldeaglemall.com/' }}
    />
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  paragraph: {
    margin: 24,
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
  },
});
import*as React from'React';
从“react native”导入{Text,View,StyleSheet};
从“expo常量”导入常量;
从“react native WebView”导入{WebView};
//可以从本地文件导入
从“./components/AssetExample”导入AssetExample;
//或npm中可用的任何纯javascript模块
从“react native paper”导入{Card};
导出默认函数App(){
返回(
);
}
const styles=StyleSheet.create({
容器:{
弹性:1,
为内容辩护:“中心”,
paddingTop:Constants.statusBarHeight,
背景颜色:“#ecf0f1”,
填充:8,
},
第段:{
差额:24,
尺码:18,
fontWeight:'粗体',
textAlign:'中心',
},
});
但我无法添加一个10秒时间的启动屏幕来显示。追逐谷歌搜索并没有把我带到任何地方。我需要做什么修改才能完成上面的代码

编辑:

闪屏基于世博会文档中的示例工作


但是下面的答案会在启动屏幕之后出现一个白色屏幕,它会一直保持在白色屏幕上,并且永远不会进入网络视图。

您可以使用
SplashScreen.preventAutoHideAsync()
(由提供)使本机启动屏幕保持可见,直到调用
SplashScreen.hideAsync()

将包添加到依赖项中

$ expo install expo-splash-screen
然后,像这样使用它:

import*as React from'React';
从“react native”导入{Text,View,StyleSheet};
从“expo常量”导入常量;
从“react native WebView”导入{WebView};
从“世博会闪屏”导入*作为闪屏;//console.log(`SplashScreen.preventAutoHideAsync()成功:${result}`)
.catch(console.warn);//显式地捕获并检查任何错误是很好的
导出默认函数App(){
React.useffect(()=>{
setTimeout(异步()=>{
等待SplashScreen.hideAsync();

},5000);//没有启动画面吗?启动后,屏幕保持白色,页面永远无法完成加载。@Zanam您是否在
app.json
(在
expo.splash.image
下)中设置了启动画面?您是否检查了中提供的示例?是否可以更新您的问题以包含更多详细信息?更新了问题。