我在 Webview 中有一个 url,例如https://www.nytimes.com/ 当前代码在页面加载时有效,但如果我在链接中键入点击任何内容,则页面需要一段时间才能加载,并且页面中没有加载指示器网站。当我们单击任何链接或页面加载时,有什么方法可以在 React Native 中放置页面加载指示器,特别是如果它是像下一个 js 一样在服务器端渲染的?
这是我的 ReactNative 代码。
import * as React from 'react';
import {
View,
Text,
Image,
SafeAreaView,
ScrollView,
TextInput,
TouchableOpacity,
} from 'react-native';
import styles from './styles';
import { WebView } from 'react-native-webview';
// import WelcomeSwiper from '../../components/WelcomeScreen/WelcomeSwiper';
import LoadingIcon from '../../components/Loading/index.js';
const WebView = ({ navigation }) => {
return (
<SafeAreaView style={styles.container}>
<WebView
javaScriptEnabled={true}
domStorageEnabled={true}
renderLoading={LoadingIcon}
source={{ uri: 'https://www.nytimes.com/ ' }}
startInLoadingState={true}
/>
</SafeAreaView>
);
};
export default WebView; …Run Code Online (Sandbox Code Playgroud)